The Mouse Vs. The Python

Python Programming from the Frontlines

This week, I discovered a new book on Python titled Treading on Python Vol. 1 by Matt Harrison. The book is only in draft form, so it’s still pretty rough, but the author was kind enough to send me a free copy in epub and mobi formats. I read part of it using EPUBReader, an add-on to Firefox so I could read it in my browser. Then I switched to the PC Kindle software to finish the book.

The book is your typical introductory text to Python. I felt like it was a tad shorter than some of the intro books I’ve read though, but that may be because it was an eBook. He covers what you would expect, but here’s a short list of topics:

Installation of Python

The Interpreter

Numbers and Strings

dir and help (introspection, although he never uses that word)

comments

Sequences (lists, tuples and dicts)

Functions, Classes, and Methods

File I/O

Exceptions – very brief, doesn’t show how to make your own

He uses a few odd terms that I’ve never heard, like calling the double-underscore methods of Python “dunder methods” (like __init__ or __seq__). The only name I’ve ever heard for those are “magic methods”. He also says the following: It is common to hear in Python parlance of “truthy” or “falsey” (Kindle location 700) regarding bools and bool-like objects. I’ve read a lot of books on Python and never come across that before either. It’s no big deal, they just kind of jumped out at me and left me scratching my head.

Anyway, I can’t be too hard on it because it’s still only a draft. I did notice that some of the first sections in the book seem to get repeated later on. I’m not sure if that was intentional or not. Maybe it was a way of emphasizing the material. Regardless, the information in the book is pretty good for someone who is just coming to the language. I should mention that it’s more of an overview book though. Every topic has only 1-4 pages of information on it on average, so this book will give you enough information to get going, but you’ll still need to read the docs if you hit a wall. For example, he mentions comprehensions, but never says what they are. You don’t need those when you program, but they sure can be nice. On the other hand, he does talk about the “with” statement quite a bit.

Overall, I would say this is a pretty good introductory text on Python. The reader will get a nice overview of the language without the confusion of 3rd party packages or even very much of the included modules. They get a little introduction to Python introspection tools, which is pretty nice. When the book is finished, this is one you may want to keep in mind for your budding Pythonista. You can actually purchase the book from his website now for $4.99 and I think you get the final version when it’s done, kind of like Manning’s Early Access Program (MEAP).

Anonymous

Mike –

I really appreciate the candid review and feedback. I will be incorporating what I can into the book. I’d love to hear if there other sections that are too short-winded. I’ll certainly add a section on defining custom exceptions.

As the focus of the book is Beginning Python, (the next volume will deal with fun stuff like functional programming, generators, comprehensions, decorators, and context managers), it tries to discuss only the basics that a programmer will need to grok Python quickly. I believe newbies to Python should be able to jump into Django or Numpy or GUI development, after reading the book and be able to focus on the problem at hand.

I’m also adding a chapter on testing unittest and doctest, and will be releasing free material soon — practice assignments and a beginning cheatsheet.

WRT “dunder”, that term has certainly been thrown around at PyCON. Maybe now that Michael Scott is gone, I should revert to magic methods

http://hynek.me/ Hynek Schlawack

FWIW, Raymond Hettinger uses the “dunder” name in his talks.

http://twitter.com/kaleissin kaleissin

Might be the terms are a regional thing? It’s a big planet after all. Anyway, I’ve always said __ as under-under, and “dunder” sure is a fair enough shortening of that.

Anonymous

Really? I don’t think I ever heard him say it in his Advanced Python tutorial last year. Oh well. My bad.

Anonymous

I figured this was primarily a beginner’s book. I hope I didn’t sound too critical. I thought it was pretty good, which is why I said that budding Pythonistas should take a look. I thought there might be another volume in the pipeline with more advanced stuff too. I’ll send you an email with my other thoughts and a weird error I saw in the text.