Python books have moved steadily to occupy larger shares of bookstore shelf space. Since I started these roundups, the number of dead-tree titles on Python has probably doubled twice. And this says nothing of the many excellent electronic documents about Python out there on the Web (including some full-length books). This article touches on a handful of Python books that have made it to my bookshelf in the last months.
Two books on Python and the Web
I recently received two titles that cover almost the same range of material: Holden and Beazley's Python Web Programming and Thiruvathukal, Christopher, and Shafaee's Web Programming in Python. Both reflect well on the excellent reputations of their respective publishers, New Riders and Prentice Hall. It is hard to recommend one of these over the other, so let me point to a few differences.
Python Web Programming has quite a good introduction to XML programming in Python. Not as extensive as Python & XML (discussed below), but a solid start. Web Programming in Python, in contrast, omits XML, but provides introductions (as the full title indicates) to Linux, Apache, and MySQL. Both books spend somewhere around 100 pages explaining Python itself, but Python Web Programming does quite a bit more on the general networking libraries that come with Python. Both books end with some sample concrete applications, based on the various topics covered earlier, but Web Programming in Python is probably a better choice if your goal is to use the samples as templates for your own development project -- meanwhile, Python Web Programming has a bit more of a reference/academic feel to it.
Both books contain indices, but Python Web Programming adds to that a glossary (helpful in the world of Internet acronyms) and an appendix on changes in Python versions. You will not go wrong with either title (assuming you are looking for something on Python and the Web), but Web Programming in Python feels a bit handier for a site-developer. Assuming you do want to use Linux, Apache, and MySQL, along with Python, Web Programming in Python gives you enough to work with, without requiring two or three additional books. Of course, if you insist on using Windows or, even worse, IIS/MSSQL for your site, less of Web Programming in Python is relevant. Python Web Programming (mostly) sticks to material relevant across platforms.
The short of it is that Jones and Drake's Python & XML is the book you should buy if you want to work with XML in Python. McGrath's XML Processing with Python, which I reviewed previously, covers a similar range of material. But in most every respect, I prefer Jones and Drake's book. The writing in Python & XML is clear, detailed, and generally precise -- certainly in comparison to the XML standards documents it paraphrases. There are a couple of points where the intricacies of XML are characterized slightly wrong -- such as the implication on page 27 that there are four rather than five inherent entities (omitting &) -- but in general, this is the best book I have encountered for understanding XML.
As the title may or may not indicate, Python & XML is really a book about XML, not one about Python. That is, it contains no explanation of the Python language as such -- readers are assumed to understand Python (but not necessarily the XML libraries). The XML libraries addressed are basically fourfold: the built-in support in Python 2.0+; the PyXML (of the XML-SIG); Fourthought Inc.'s 4Suite; and bindings for MSXML (on Windows). Brief mention is made in an appendix of some other libraries. In general, the examples in the book are compatible with Python's Standard Library XML support.
Books for learning the language
Thomas W. Christopher's Python Programming Patterns is an unusual book in the Python repertoire. The title is obviously intended as a reference to the famous Design Patterns: Elements of Reusable Object-Oriented Software by the so-called "Gang of Four (GoF)" -- Gamma, Helm, Johnson, and Vlissides. But Python Programming Patterns is not really a recapitulation of that other title into Python examples; rather it tries at the same time to do that, and to be a first book on Python itself. A few strikingly negative notices about Christopher's title have appeared on comp.lang.python. While I agree it has some weaknesses, I think the sentiment misunderstands the intent of the book.
I think of Python Programming Patterns not so much as a book about Python, but as a book about programming. Each chapter introduces some new Python constructs, while simultaneously using those constructs to explain a few general computer science concepts. As such, the target for Christopher's book is not so much a person trying to pick up Python as it is an introductory to middle-level course in computer science. Some of the general concepts are interesting for even an advanced programmer to review. That said, for its best matched purpose, Python Programming Patterns spends far too much time explaining basic Python constructs. Someone advanced enough to understand the "patterns" will get Python syntax quicker than this; someone just beginning programming will have the abstract concepts completely lost on them. The book could use a bit better focus, overall.
Visual QuickStart Guide: Python
The cover of Chris Fehily's book for Peachpit Press boldly proclaims, "Teach yourself Python the quick and easy way! This Visual QuickStart Guide uses pictures rather than lengthy explanations. You'll be up and running in no time!" Stop for a moment, and contemplate what the publisher decides to put in 36 point font. To my mind, this is a decidedly inauspicious beginning.
Visual QuickStart Guide: Python is chock full of pictures, on literally every page. Many of these are semi-relevant shell session samples; but quite a few others are almost completely superfluous pictures of Web pages or code listings that include the window decorations of Fehily's text editor (usually under MacOS, in case anyone cares, but sometimes under Windows 2000). In some cases some genuinely helpful tables and diagrams make it in there too. Fehily's actual writing is pretty good. But he is constrained by the publisher's style, which precedes every paragraph by one of a half dozen different bullet styles (each apparently indicating something about the paragraph). The little quips are well chosen and interesting, but it doesn't make for very systematic study of the Python language.
On a lark, I decided to look up a moderately obscure topic, the .__delattr__() magic method. The index has no
listing for this, and I presume it is not discussed. Fair enough...this
book is for beginners. There is, however, a listing for the delattr() built-in function. On page 261 we find a
heading called "Manipulating Attributes," with a subheading that describes
delattr(). With the busy page, I initially
thought the form del obj.attr was omitted
entirely; but it is mentioned in a little floating bullet elsewhere
on the page. Even so, we are simply told that the two are equivalent (with
no hint as to why both exist). If I did not have a good knowledge of
Python, I think I would get the impression that it was a badly thought out
language (rather than one that can deal with transient object names).
There has been lot of good buzz around Wesley Chun's Core Python Programming. It turns out that all the buzz is well earned. I think this is the best book currently available for learning Python independently (unless you are completely new to programming, in which case, you are better off with Gauld's Learn to Program Using Python). I would recommend Chun's book over Learning Python, Programming Python, or The Quick Python Book, all of which are good; and I would certainly recommend any of these over Programming with Python or Python: Annotated Archives, neither of which I liked much. Python 2.1 Bible was also good, but written for a somewhat more advanced audience. (See the Resources section for links to columns that review the other books mentioned here.)
The strategy of Core Python Programming is a logical, progressive presentation of various Python features; but the book is organized well enough into chapters, which you do not necessarily need to read in order. Core Python Programming is not terrible as a reference, but it is better suited to learning Python from scratch. One thing I really like about Chun's approach is that he is generous with presenting code samples illustrating each concept (but does not attempt to build a single growing application, as some texts do -- an approach I find slightly contrived). The explanation, organization, and typography is clear throughout (although the bottom margins are sometimes extremely small, even while the other margins are generous, which looks odd).
The one complaint I have with Chun's book is that it is physically larger than the others and this makes it somewhat cumbersome to carry. As a desk reference, the size is OK, but as a learning text, it is too big. The font is rather large, and the paper rather thick. This, together with the length of the book (roughly 800 pages once you count the non-numbered pages), makes it a hefty book. Reducing the physical weight by 30% would be possible without losing any content, and would make for a more useful volume (maybe in the next edition!).
Python Pocket Reference, 2nd Edition
When I last looked at Mark Lutz' Python Pocket Reference, it was in its first edition. Since then, Python has gone through some new versions, and Lutz and O'Reilly have updated this thin volume. The obvious change, and what probably chiefly motivated the update, is the coverage of Python 2 in the second edition. But in the process of getting updated, the Python Pocket Reference has grown from 74 to 124 pages, nudging it into somewhat more substantial territory. My previous complaints still hold for the most part: there is no index, and most of the time, no real advantage over the online Language and Library references. But the few extra pages make it by and large a better book.
Beyond documenting new features, periodic clarifications are added to the explanations of existing Python features -- just enough possibly to warrant carrying the book around. Of course, the cover price has increased along with the size, from $6.95 (USD) to $11.95 (USD). That may still be more than it is worth for someone who does not get free review copies.
A company called Prime Time Freeware publishes a number of books with an interesting twist to them. All of their titles are based on documents in the public domain, or under liberal, royalty-free licenses. They call this their "Documenting Open Source Software for Industry, Education and Research (DOSSIER)" series, and two of these books are about Python: Python: Library Reference and Python: Miscellanea. The first covers exactly what the title says, the latter includes a number of smaller documents, such as Greg Ward's "Distributing Python Modules," Fred Drake's "Documenting Python," the Python Reference Manual, the Python Tutorial, and other documents taken from python.org. One set of documents omitted would, in my opinion, be valuable to include -- Andrew Kuchling's excellent series "What's New in Python X.X?" is the best way to see what has changed between versions.
There is not much I can really add about the content of these books. You can read them for yourself online, and I have previously praised the high quality of Python's standard documentation. I can observe that the DOSSIER books are nicely laid out, with a good font and paper stock, and an attractive (although common between titles) cover design. Apparently the series is physically printed in a print-on-demand arrangement, to avoid warehousing copies. As such, I might expect the documentation to be more up-to-date than Python 2.0 (the layout is some work, but it is closely based on what the Python team provides as LaTeX, Postscript, or other printable formats). Moreover, as much as I like printed books, I am not sure that $35 is really a fair price for otherwise free words (especially since commercially copyrighted books usually sell at a discount from cover price). The DOSSIER books are available through Prime Time Freeware's Web site (shipped by BSDMall), and do not carry an ISBN.
Authors and publishers who have titles they would like me to review are encouraged to contact me at my e-mail address. I will try to work in as much future coverage of books as space allows.
- Read the previous installments of Charming Python.
-
Python
Web Programming
, Steve Holden with David Beazley, New
Riders, 2002. ISBN: 0-7357-1090-2.
-
Web
Programming in Python: Techniques for Integrating Linux, Apache, and
MySQL
, George K. Thiruvathukal, Thomas W. Christopher
& John P. Shafaee, Prentice Hall, 2002. ISBN: 0-13-041065-9.
-
Python &
XML
, Christopher A. Jones and Fred L. Drake, Jr.,
O'Reilly 2002. ISBN: 0-596-00128-2.
-
XML
Processing with Python
, Sean McGrath, Prentice Hall,
2000. ISBN: 0-13-021119-2.
-
Python
Programming Patterns
, Thomas W. Christopher, Prentice
Hall 2002. ISBN: 0-13-040956-1.
-
Visual QuickStart
Guide: Python
, Chris Fehily, Peachpit Press, 2002. ISBN:
0-201074884-3.
-
Programming Python, Learning
Python, and The Quick Python Book
-- all mentioned in this article -- were reviewed in our first Charming
Python book roundup: Charming
Python: Updating your Python reading list (developerWorks, February 2001).
-
Learn to Program Using Python,
Python: Annotated Archives,
Programming with Python, and Python
2.1 Bible -- also mentioned in this article -- were reviewed
when next we reviewed Python books: Charming
Python: Updating your Python reading list, Part 2 (developerWorks, November 2001).
-
Core
Python Programming
, Wesley J. Chun, Prentice Hall, 2001.
ISBN: 0-13-026036-3.
-
Python Pocket Reference,
2nd Edition
, Mark Lutz, O'Reilly, 2002. ISBN:
1-596-00189-4.
- Examine Prime Time Freeware's titles.
-
Andrew Kuchling's "What's New" series can be found on his Web site
(along with some other documents and modules he has
written).
- Find more Linux articles in the developerWorks Linux zone.

David Mertz' failures as a hunter, fisherman, and shepherd have led him to his life of critical criticism. Tomorrow he may try something else. David may be reached at mertz@gnosis.cx; his life pored over at http://gnosis.cx/dW/. Suggestions and recommendations on this, past, or future columns are welcome.


