As I mentioned, I got started with the PyAtl Book Club at the May meeting. The first book I received was Expert Python Programming, by Tarek Ziadé. Part of the deal with the book club is posting a review of the book, so I will be posting about the book as I work my way through it.
Chapter 1
This is basic setup info (though the vim section has a nice selection of config settings for those new to it), so I won’t really cover it; I already have multiple versions of Python running on my dev box.
Chapter 2
This chapter is entitled “Syntax Best Practices—Below the Class
Level”, and that’s a pretty accurate description. There’s a short
section on List Comprehensions followed by a longer
section on Iterators and Generators.
This is a fast but detailed look at the subject, including the use
of send and coroutines
(via the mechanisms defined in PEP 342). The treatment is
rather brief, so I recommend David Beazley’s A Curious Course on
Coroutines and Concurrency for more detail. Up
next are genexps (defined in PEP 289). These
were added in Python 2.4. This section is short and to the point: use
genexps wherever you would use a list comprehension unless you need
some feature of lists that a generator lacks. The next section is a
brief glimpse at itertools. It is hardly complete,
but it does highlight one of the (IMO) most interesting pieces of
the module: tee. This function makes it practical to use
genexps even when you need to make multiple passes across the data.
Up next is the section on decorators (defined in
PEP 318), which were introduced with Python 2.4. The author
addresses decorators in much more detail than the previous topics, with
extended examples of using them for various things such as caching,
proxies, and context providers. That last provides a nice segue into
the next session, where he shows us how to replace context provider
decorators by using the with statement (defined in
PEP 343) introduced in Python 2.5. The author does a pretty
thorough job of explaining what with
is doing and how you can use it
to good effect, including how to use the contextlib
module (introduced at the same time as the with
statement) to use
context managers with code that doesn’t provide
them out of the box.
Thoughts
Although it was a bit whirlwind at times, the author does a good job of covering the modern language constructs that Python has picked up in the last few versions. Although you may want to read a more detailed tutorial on a given feature, this chapter does a good job of getting you up to speed with modern Python.
Back to flipping out…