Python Essential Reference

Beazley, David M.
New Riders
ISBN 0-7357-0901-7
318pp
Date finished: 1999-12-12

Summary: The word "essential" in the title is well deserved; while it's too condensed to be a first introduction to Python, intermediate and advanced programmers will find it valuable as a reference. 5 coils out of 5.

This book is like a combination of the Language Reference and Library Reference, condensed and rewritten. The body of the book is actually less than a hundred pages, with Appendix A's module documentation forming the bulk of the book.

Chapter 1 is an 11-page tutorial, and then the book embarks on a careful explanation of Python syntax and semantics for the next 9 chapters, 75 more pages in all. The explanation is written in careful, semi-formal style:

Although the assignment of attributes is always performed on the local dictionary of an instance, attribute access is somewhat more complicated. Whenever an attribute is accessed, the interpreter first searches the dictionary of the instance. If no match is found, the interpreter searches the dictionary of the class object used to create the instance. If this fails, a search of base classes is performed. If this fails, a final attempt to find the attribute is made by attempting to invoke the __getattr__() method of the class (if defined). If this fails, an AttributeError exception is raised.

From Chapter 7, "Classes and Object-Oriented Programming"

Unless you're really motivated, this type of prose isn't well-suited as an introduction to Python, but it's great when you can't quite remember the semantics of a particular language feature. New Pythoneers need longer, more gradual explanations, so they should look for a different book; the Essential Reference comes into its own for intermediate and advanced Python programmers.

Appendix A takes up over 150 pages with a reference guide to the most commonly used modules in Python's standard library. Add-ons such as Numeric Python are not covered; the most important standard module that's omitted is Tkinter, which is large enough to require a book of its own. While all the modules are already covered in the Library Reference at python.org, the Essential Reference drops many modules that are platform-specific or of marginal usefulness, uses different examples, and tries to explain operating system features enough to minimize the need to refer to man pages. At times the explanations can be very good; the coverage of the threading module stands out in my mind, for example.

Appendix B is a 30-page discussion of compiling Python, writing C extensions, and embedding a Python interpreter in a larger program. The complete guide to extending Python hasn't yet been written, and you'll still need to refer to the Extending/Embedding and Python/C API manuals for a more complete picture, but it's a helpful introduction that actually taught me about some new features (mostly format characters for PyArg_ParseTuple() and PyArg_BuildValue that I didn't know about).

The typography is clear and readable, though the fonts used are perhaps a bit small, and the monospace font used doesn't confuse single quotes and backticks. An unexpected surprise on the very last page of the book is Ivan van Laningham's short essay on the choice of a Mayan pyramid as the cover image. Take 2 minutes to read it in the bookstore, if nothing else; van Laningham, whose paper on the Mayan calendar was a highlight of the 7th Python conference, has written a beautiful little summary of Mayan beliefs.

My only small reservation is the price. It's definitely worth US$34.95 (CDN$52.95, UKĀ£25.50), because the Essential Reference condenses a very large amount of material into a single volume, but suspect it would find many more purchasers if New Riders priced it closer to $20-25.

(A second edition of this book is now available, updating it for Python 2.0 and preserving the virtues of the first edition. The cover image is different, however, and van Laningham's page-long essay is now gone.)

Tagged: programming languages, python

Permalink: http://books.amk.ca/1999/12/Python_Essential_Reference.html

%T  Python Essential Reference
%@  1999-12-12
%A  Beazley, David M.
%*  *
%K  Python, programming languages
%P  318pp
%G  ISBN 0-7357-0901-7
%I  New Riders

http://books.amk.ca

Contact me