Review: Expert Python Programming

2009-04-16, Comments

Expert Python Programming cover Tarek Ziadé

If you follow Python blogs you’ll have seen more than one review of Tarek Ziadé’s book, Expert Python Programming. As a result of these reviews I’d decided that, although the book looked interesting, I wouldn’t be investing in a copy for myself; but when the publishers contacted me directly with the offer of a free review copy, I accepted.

You may wonder: Why the need for a book on expert Python programming? Doesn’t Python value simplicity and transparency above all else? (Language lawyers and golfers, look elsewhere!) Why any book on Python, when the online documentation is so well put together?

Yes, that’s what I thought too, but the fact is, Python has steadily expanded over a series of point releases. The standard tutorial omits important new(-ish) features such as decorators and properties, and its treatment of generators and special methods is light. Although the language reference covers these topics, it’s no user guide.

Expert Python Programming starts well, picking up where the Python tutorial leaves off. It soon becomes evident Tarek Ziadé is indeed an expert Python programmer. He walks through some nice real-world examples. He presents guidelines and advanced idioms few Pythonistas would dispute. He points to tools, modules and articles hosted on and away from with accuracy.

Unfortunately the details let the book down. Graphics are poor quality. Some screen shots are barely readable. Here’s a broken code sample — it’s not the only one.

>>> def sum(sequence):   # better !
...     total = 0
...     for arg in args:
...         total += arg
...     return total

(While I’m nit-picking, I wish books didn’t resort to comments for call-out text, and I’d prefer an example which doesn’t shadow a built-in function).

I’m less bothered by the grammatical errors and typos. Tarek Ziadé writes clearly and engagingly. The book is easy to read. That said, I won’t let him get away with this pronouncement on Test-Driven Development (TDD).

[TDD] is widely used in the Python community, and probably more so in communities that work with statically typed languages. This may be due to the fact that developers think that most tests are done by the compiler, which checks many things when it produces a binary.

  1. I’m sure he means “more so than in communities …”.
  2. The negative spin may well irritate some readers unnecessarily.
  3. Which is a shame, since I agree with the point he’s trying to make, that strong testing beats static typing.

Further in, the book covers more general software engineering discipline, with chapters on packaging and distribution, version control, project tracking, documentation, optimisation etc. As ever, Tarek Ziadé provides some welcome pointers to Python best practices, but I see little point in (e.g.) supplying sample Trac configuration file listings — it would be better to direct readers to up to date online documentation.

Once you get beyond the core language, Python becomes a sizable topic. It must have been hard to decide what belongs in a book for expert Python programmers, and what to leave out. I do think there should have been more about Python 3.0. I would also suggest coverage of embedding and extending — of interfacing with other languages.

In summary, then, I enjoyed Expert Python Programming and learned a few things from it. I don’t think I’ll return to it often, but it has provided some useful pointers. With careful editing and design it could have been much better.

At a slight tangent, but still on the topic of expert Python programming, I recommend David M. Beazley’s “A Curious Course on Coroutines and Concurrency”, originally presented at PyCon’09. It sort-of follows on from his equally good “Generator Tricks for Systems Programmers” PyCon’08 presentation but this time he’s pushing rather than pulling.

David Beazley

Dave working on his latest project — “you know, it’s a series of tubes.”