David Mertz, Ph.D.
Machinist, Gnosis Software, Inc.
In a bit more than a year the Python community has gone from having a thin selection of books to recommend to the current forest of dead trees available to help with learning and programming in Python. Some books are general introductions to the Python language, while others specialize in particular tasks. Even within the general books, level and focus differs considerably. This column gives the David's impressions and recommendations on eight of the best known books about Python.
Python is a freely available, very-high-level, interpreted language developed by Guido van Rossum. It combines a clear syntax with powerful (but optional) object-oriented semantics. Python is available for almost every computer platform you might find yourself working on, and has strong portability between platforms.
This column should provide readers with a good guide to most of the books on Python currently available for purchase. As of this writing, I know of a few books that are available--or are expected to be available soon--that I have simply not had the opportunity to look at. By the time you read this, more may have been announced and/or published. It is an exciting time to be a Python programmer; in some part because computer book publishers are catching on to how "hot" Python is as a programming language. I apologize to any author or publisher that has slipped completely by my notice, but I will mention the following titles that are not reviewed here, but that readers might still want to investigate on their own:
* Core Python Programming, Wesley J. Chun, Prentice Hall (December 2000).
* Python Annotated Archives, Martin C. Brown, McGraw-Hill (December 1999).
* Programming with Python, Tim Altom, Prima Publishing (October 1999).
* Sams Teach Yourself Python in 24 Hours, Ivan Van Laningham, Sams (May 2000).
* Python: Developer's Handbook, Andre dos Santos Lessa, Sams (December 2000).
* Learn to Program Using Python, Alan Gauld, Addison-Wesley (January 2001).
* Internet Programming with Python, Aaron Watters, et alia, Hungry Minds (September 1996). Out of print.
While books are a wonderful way to get started with most topics (including Python), there is also very good documentation that accompanies Python itself. Take a look at: http://python.org/doc/ to get yourself started. The Python team have written a quite excellent introductory tutorial, and the quality of the the module index, library reference, language reference are much better than most programming languages, or free software in general, has (but the distinction between the latter two items is always fuzzy to me when I go to look something up... try both if in doubt).
One "book" that is not discussed in this column is an unfortunate ommission. The Standard Python Library is written by Fredrik Lundh, who is truly one of the great resources of the Python community (called the "eff-bot" after his machinic rigor and his signature "/F"). General sentiment is that this is a well-written book; but it is only available in "encrypted" electronic form. Many attempted users have complained of many annoyance with the book breaking and/or disabling itself when computer hardware/software changes; and in the best of cases, the eff-bot book is currently Win32-only. Your humble author has had similar problems with other Glassbook-format titles. Overall, this electronic distribution approach is just simply not one I can endorse; so I simply passed on attempting to dig up a Win32 machine to devote to restricted reading of this text. Mind you, I have nothing generally against electronic texts (my column as you are probably reading it is an electronic text). But "copy protection" obscurantism is a strong-arm tactic which is politically contemptible, grants far less "rights" than do printed books, and is fragile waste of users time. The good news is that this same text is due to be published in dead-tree form this coming year.
Programmers who already know Python--or perhaps who do not know Python, but know other programming language with similar capabilities--will be best served picking up a reference book to provide them with gentle reminders of syntax, modules, and available functions. For books of this sort, one rarely wants to read cover-to-cover, but a good quality index is essential. Information should be grouped logically and compactly.
The Python Pocket Reference is a thin 75 page, small-format book. More than anything, Python Pocket Reference resembles a set of 3x5 index cards one might keep to jog your memory on a topic (the actual size is slightly larger, but not that much). Basically, Python Pocket Reference has lists of everything that can helpfully be listed about Python: command-line arguments; environment variables; operators; keywords; syntax rules for statements; builtin functions; magic methods; and the capabilities of the most important standard modules (and a few other things). It is easy to scan through an appropriate list, once you have a general idea about the type of thing you are looking for.
Missing from Python Pocket Reference is any index or cross-references. The book is short enough that it is not too hard to skim a relevant section, but an explicit index would be an improvement (an extra five pages at the end would not push it past "pocket sized"). Examples are also rare in Python Pocket Reference; a function's arguments might be listed, for example, but an example or two would be a useful addition in many cases. Overall, I find Python Pocket Reference just a bit too thin and summary to be of huge use, especially since I generally have the library reference and language reference a few keystrokes away at those times I need the sort of answer Python Pocket Reference will provide.
More to my own taste is the excellent Python Essential Reference. At 320 pages and with an academic-paperback form factor, Python Essential Reference is a lot easier to carry around than any of the other Python books reviewed below. But do not expect to fit it in any pockets (maybe an outside pocket of a winter-jacket). As well, the book is set in an 8 or 9-point typeface (a clean serif face with nice use of fixed, sans serif, and demibold contrasts for examples, lists, and so on). This makes for a lot more words packed into a reasonable size, but also is likely to make for some squinting and leaning over for those programmers with less-than-perfect vision.
Python Essential Reference is simply excellent in both writing clarity and editorial aids. The index is extremely professional, and points you competently to relevant sections (it neither underindexes nor overindexes, both of which are pitfalls for computer topics). I might quibble with the typographic choice of serif-bold for the index main items, which feels too heavy, but that is a trifle. In addition, many sections contain inline "See also" notes that list page numbers and section titles. This brings the power of hypertext to the convenience of a bound volume.
The general topics covered by Python Essential Reference are similar to those in Python Pocket Reference, but with more detail of coverage, and with more coverage of extension modules. As well, most formal description is accompanied by well chosen examples of a function/module/construct in action. The remarkable thing Beazley has accomplished is to organize related concepts in such a way that you can get a quick sense of a given function by reading its subsection, but reading a whole section or chapter nonetheless has a natural flow to it. Python Essential Reference has some brief introductory material to Python as a language, which might suffice for a programmer with experience in several other languages, but for someone really getting started, one of the below texts is a better choice for a first book (but get Beazley's anyway, to refer to later).
The godfather of Python books is Mark Lutz' Programming Python. I am not certain whether it was the first book published on Python, but for several years it was the standard one to refer users to. Programming Python is fairly ambitious as a project. It is one of those 900 page computer references one finds in stores, but without the fluff and filler of many such tomes. Lutz's general approach is to introduce readers to Python by way of an expanding example program (an archive program). Each introduced Python feature is utilized to add new features to the sample program, including things like a graphic interface with Tkinter and some basic OOP design considerations (some other examples are used along the way, as needed). This is one good approach (not necessarily the only one) for fairly novice programmers, but is a little slow for experienced ones.
Despite its virtues, it is difficult to really recommend Programming Python at this point. Being published in 1996, Programming Python feels a bit out of date; Python is a conservative language, and little you would learn is actually inaccurate now, but in the last 4-5 years quite a few new moudles have been added, and even a few important new inherent language features (especially with Python 2, which is not yet in any of the books). However, if rumors of a new edition prove true, this book could get a new life.
Learning Python is in some ways a successor for Programming Python. Learning Python is also an O'Reilly title, and is also (co-authored) by Mark Lutz. At 365 pages and the same 9.5" x 7" form factor as most O'Reilly books, Learning Python is a quicker read than Programming Python. The idea of running one example throughout the book has been dropped, probably in conjunction with aiming slightly less at completely beginning programmers. But Learning Python is still quite gentle as an introduction, with every feature explained in sufficient detail for, e.g., a (bright) high school student who has not previously encountered that programming concept.
In strucuture, Learning Python is composed of a series of chapters that build on each other in a logical fashion. Local examples and source code are provided along the way as a way to see each feature in a (limited) real-world context. The tone is conversational, with liberal use of 2nd person and 1st person plural. The editing, as with all O'Reilly books, is careful and consistent. The final chapters throw in bits and pieces of special topics: COM, Tkinter, JPython, etc. These feel a little bit out of place, neither intergrated with the main text, nor quite detailed enough to stand on their own.
The Quick Python Book is something like a cross between Python Essential Reference and Learning Python. Superficially, it is the size of the latter with the typography of the former. The goal of The Quick Python Book is to serve as an introductory text which simultaneously is usable as a reference to go back to. Topics are organized in subsections, each introduced in a tone that is more descriptive than Learning Python, but more conversational than Python Essential Reference. A good range of topics are covered: basic language features and standard modules; Tkinter; COM; JPython; OS specific usage.
The Quick Python Book aims at a more sophisticated reader than Learning Python does. You can learn Python from the The Quick Python Book, but you should start out with some experience in other programming languages. And the index is strong enough that this is a book you can usefully refer back to later. Overall, I would say that if you can only buy one Python book, buy The Quick Python Book. That said, if you can buy more than one, Python Essential Reference is better for referring back to, which sort of undermines one of the two goals of The Quick Python Book.
Sometimes what you want is not a general book on Python, but one that goes into greater detail on performing a specific task, or working in a specific environment. Three such titles are available (obviously, they are what you want only if they cover your particular area of interest).
Python and Tkinter Programming cover just what you would
expect: working with the
Tkinter wrapper for the
library (available on many OS platforms). It runs a fairly
lengthy 650 pages, but much of that is code samples and
screenshots. In the context of learning a GUI library, these
screenshots are helpful in visualizing what a widget really
does (or a layout, etc). The code is probably a little longer
than is really helpful, however. As various
are introduced, complete little applications utilizing them are
given as code samples. But it is unlikely you will actually
use Grayson's specific applications yourself, and seeing ten
widget of the same type created does not really illustrate much
more that seeing one created. That said, Grayson does a good
job presenting his subject, and a few extra pages of examples
does not really hurt the book. The first 2/3 of Python and
Tkinter Programming is narrative in quality, and leads a
reader through building the examples. The final 1/3 provides a
reference for all the possible
Tkinter arguments and methods.
XML Processing with Python is a quirky book. It presents
quite a bit of general introduction to Python (certainly more
than the other specialized books), but very little by way of
introduction to XML. That is, McGrath's book is useful for XML
users/programmers approaching Python, but not nearly as much for
Python programmers approaching XML (the title would suggest the
opposite to me). Also, XML Processing with Python uses a
rather large font, plenty of whitespace, and moderately thick
paper--I suspect it has fallen into a "priced by the pound"
gimmick of many recent computer-topic books. The other odd
thing about XML Processing in Python is the degree to which
it pushes McGrath's
pyxie library as a way to handle XML
pyxie is actually a very nice concept that
transforms XML into a line-oriented--and more easily parsed and
PYX. The approach is a good one, but
probably a lot more programmers will still want to use more
standard techniques like SAX and DOM. Fortunately, McGrath
does provide reasonable introductions to SAX and DOM as well,
but in the end he really wants you to use
pyxie (which is
free software, so it is not a commercial plug).
I must confess that I have had less opportunity to evaluate Python Programming on Win32 than I have most of the others. I just do not use the Win32 platform enough to have undertaken any real projects for which I would need this book. However, the authors certainly have immaculate credentials: Mark Hammond is creator of the PythonWin IDE, PythonCOM, and Python for .NET. He knows Windows, and he has done a lot for the Python community. In tone, Python Programming for Win32 is pretty similar to Learning Python. Both are fairly conversational, and lead readers through a logically arranged succession of topics. Python Programming on Win32 provides a pretty quick introduction to Python in general, then moves on to working with all the specifics of the Windows platform: COM, ODBC, ActiveScripting, and other aspects. Python makes a really nice fit for Windows, actually; all those chores you might otherwise do in VB or VBScript--scripting MS-Office applications, maintaining the registry and configurations, creating ASP pages for IIS, etc.--are simply easier to do if you use Python instead. Python Programming on Win32 is a good introduction to doing this very set of things.
Python Essential Reference, David M. Beazley, New Riders 2000. ISBN: 0-7357-0901-7.
Python Pocket Reference, Mark Lutz, O'Reilly, 1998. ISBN: 1-56592-500-9.
Learning Python, Mark Lutz & David Ascher, O'Reilly, 1999. ISBN: 1-56592-464-9.
Programming Python, Mark Lutz, O'Reilly, 1996. ISBN: 1-56592-197-6.
The Quick Python Book, Daryl Harms & Kenneth McDonald, Manning, 2000. ISBN: 1-884777-74-0.
Python Programming on Win32, Mark Hammond & Andy Robinson, O'Reilly, 2000. ISBN: 1-56592-621-8.
Python and Tkinter Programming, John E. Grayson, Manning, 2000. ISBN: 1-884777-81-3.
XML Processing with Python, Sean McGrath, Prentice Hall, 2000. ISBN: 0-13-021119-2.
(the eff-bot guide to) The Standard Python Library, Fredrik Lundh, eMatter (mightwords), 1999. ISBN: 0717350770. For information see:
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 email@example.com; his life pored over athttp://gnosis.cx/publish/. Suggestions and recommendations on this, past, or future, columns are welcomed.