 | Level: Introductory David Mertz (mertz@gnosis.cx), Color commentator, Gnosis Software, Inc.
01 Nov 2001 Since my last book roundup appeared in February of 2001, a number of interesting books on Python have been published. This installment provides new comparative reviews of recent Python titles (or titles missed in the last roundup). Pre-game
Since my last book roundup nine months ago, some new Python books have been published, and some other books
have made it to my desk that I did not have a chance to review previously. I haven't got my hands on all books I hope to review, but between the two installments, almost every book you might consider buying on
Python today is discussed.
By the time next year rolls around, even more books will join
the Python bookshelf. Surely there will be new titles I have
not heard of; but here are a few that look promising.
Python stalwart and brilliant Usenet essayist Alex Martelli has
apparently contracted to write two separate books for
O'Reilly -- one titled
Python in a Nutshell
(should be interesting to see Martelli's prolific writing
inclinations squeezed into a compact size). Bruce Eckel, whose
Thinking in Java has been very well received, has had
not-yet-realized plans to write a
Thinking in Python
for a
while; perhaps he will for 2002. Christopher Jones and Fred
Drake have another O'Reilly title
Python & XML
underway,
which looks promising. And I must mention that your humble author is in
the process of writing
Text Processing in Python
for Addison-Wesley. 2002 looks to be another good year for
Python.
I have not had the
chance to look at a few currently in print Python books. No slight is
intended towards these titles, but neither can I make any
recommendation. These are:
-
Core Python Programming
, Wesley J. Chun, Prentice Hall
(December 2000)
-
Sams Teach Yourself Python in 24 Hours
, Ivan Van
Laningham, Sams (May 2000)
-
Python: Developer's Handbook
, Andre dos Santos Lessa,
Sams (December 2000)
If I have missed any books altogether, I apologize to their
publishers and authors. Let me know; I'll try to
review them in the future.
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 the Python documentation at Python.org (see Resources later in this article) to get yourself started. The Python
team has written an excellent introductory tutorial, and
the quality of the module index, library reference, and
language reference are much better than most programming
languages, or free software in general, have. (The
distinction between "library reference" and "language references" is always fuzzy to me
when I go to look something up; try both if in doubt.)
Touching some old bases
Six months ago, the one Python book I made sure to keep within
arm's reach while programming was David Beazley's Python
Essential Reference. Mind you, the rest are all within a few
steps of my chair, but Beazley's is the one I didn't have to
stand up for. That's changed a bit in the last few months -- now
the book in arm's reach is the second edition of
Python
Essential Reference
. The main change between editions is
simply an update to coverage from Python 1.5.2 to Python 2.1.
The organization and most of the content remain the same.
Apparently in response to some user complaints, the font size
was increased slightly (and the length went from 318 to 396
pages); unfortunately, at the same time the 2nd edition is
printed on paper with a much lower brightness -- readability
(from a purely physical perspective) has actually gotten
slightly worse.
Another title that was mentioned but not reviewed in the
previous installment is Fredrik Lundh's
Python Standard
Library
. At that time, only an encumbered electronic version
was available, but since then, O'Reilly has published a printed
version. Python Standard Library is a thin volume -- 281 pages
in physical size, but more lines of the books are taken up with
source code and vertical whitespace than with prose
description. The total words do not add up to a large number.
Python Standard Library has a fairly narrow target and hits it well. The target is the experienced
Python programmer who also has either the standard module
documentation and/or one of the thicker books at hand. Almost
all of the modules in Python 2.0's standard library are
covered, but the coverage is not aimed at documenting every
constant, function, and class inside each module. Instead, each
module is introduced with extremely clear and articulate prose
descriptions, followed by well-chosen typical usage examples.
Many of the other books I have looked at also use extensive
source code examples; but in many of those, you have to re-read
and ponder for a while to figure out exactly what an example is
meant to illustrate, which part of it illustrates the topic at
hand, and why it is an illustration. In contrast, the source
code examples in Python Standard Library are only as long as
necessary, are clear, have adequate inline documentation, and
get right to the point being illustrated. Likewise, the prose
introductions provide exactly the sort of clear guidance you
might ask of the more experienced programmer in the cubicle
next to yours (if you are lucky enough to have such a
co-worker). The descriptions, however, by intention do not try
to teach you basic concepts -- they assume you basically know
what you are doing, and just need to refine how you
do it.
Warming up
Learn to Program Using Python: A Tutorial for Hobbyists, Self-Starters, and Those Who Want to
Learn the Art of Programming
is probably not a book for
most readers of this column. As the title promises, Alan
Gauld's book is for non-programmers who want to become
programmers, or at least to understand what it is programmers
do. For this audience, Gauld has written a
delightful book. A non-programmer I recruited to review this book confirmed that the first few chapters seem pitched right for a beginner.
Gauld walks through a reasonable range of topics, and keeps
them in a good pedagogical sequence. The reader of this book
should read the book from one cover to the other. There is a
good index, but jumping around is not what this type of book is
for. The source code examples do an excellent job of
progressively presenting new concepts while remaining clear and
to the point. Even though many books' use of sidebars and
boxes is just busy and distracting, Gauld strikes a good
balance with his "Things to Ponder" and "Points to Remember"
that appear at the end of each chapter. Overall, this looks
like a just plain fun book to read.
Studying the playbook
There is a certain style of programming book that I have
trouble seeing the point of. Sample source code is important
in learning a programming language or technique; but a certain
type of book consists primarily of source, with the prose
existing mostly to explain the source code in a line-by-line
way. It is not merely the quantity of source code that I find
ineffective. Python Standard Library has a high proportion
of source code -- but the source code exists as a continuation
and elaboration of the prose; the source code explains rather
than merely being explained. In another style of book, the
source code just lays there as a dead mass, with the prose
vainly trying to vivify it.
Two of the books in the current roundup are in this
source-code-with-commentary category. One is
Python Annotated
Archives
. This is one of those heavy tomes that its
publisher, Osborne, is fond of (720 pages). I cannot really
recommend this book to anyone. Experienced programmers
will not be able to find reference information easily, and
beginners will lack the background to jump into any particular
script. Moreover, it almost seems to be cheating to publish
a book that just reproduces (albeit also discusses) all the
scripts in the Demo/ directory of every Python distribution
(copyrights are in order, I mean it in a "scruples" way). What
are we really getting by buying this book?
A lot of concepts inevitably occur in 700+ pages. But there is
no particular order apparent to where they occur. Here is one
arbitrary example: the use of _doc_ strings is a fairly
important convention in Python programming. A beginner would
not know about it from this book unless she happened to turn to
page 162 to find an explanation of them -- not because that page
is where documentation conventions are discussed, but just
because the script being discussed happens to have some
_doc_ strings. A handful of other pages scattered through
the book also mention, "by the way, this is a _doc_ string."
An experienced programmer is unlikely to need the explanation;
a beginner is unlikely to find it.
Moreover, the explanatory prose is haphazard (and not
infrequently wrong or incoherent -- for example, I cannot make heads or
tails of the lead-in to the very first example, prime.py).
The author, Martin Brown, just sort of throws whatever explanation comes to
mind at each block of three or four lines of each script (which
are redundantly printed, then printed again with annotation).
But if someone doesn't understand what a loop or a numeric
operation does, the place to explain it isn't next to each
loop, but in an "about loops" or "about operations" section of
the book.
Programming with Python
suffers a similar weakness to Python
Annotated Archives. The cover advertises that it's
"filled with over 40 full-length, annotated scripts." It lives
up to its promise; but the Vaults of Parnassus have many more
than 40 full-length scripts, covering a far wider range of
purposes. If you need a Python script to accomplish some
moderately complex purpose, you are a lot better off
finding one to download from a Python Internet archive, like
Parnassus (and a few dollars the richer for not buying a book).
There is a little bit of other stuff in Programming with
Python than the scripts themselves. The scripts have a little
bit of explanation -- but only a little bit. The beginning bit
of the book has a brief summary of the statements (with built-in
functions mistakenly called statements), modules, and some
Python syntax. But the Python tutorial is better. The last
few pages of the book have a pretty good set of FAQ-type
questions about Python. I haven't seen anything exactly like
that on the Web, and the questions presented are good ones,
with accurate answers. But that is only 57 pages worth of
material, and your particular questions will only be a few of
those listed.
The complete stat sheets
A popular type of computer programming book is the thick tome
dedicated to being a complete reference for a language or tool.
I've had a chance to look at three such books.
A first option for the "about everything" Python reference is
the second edition of
Programming Python
. I have already
written about the first edition (see my previous roundup), and most of what I wrote there
is still true. Programming Python has grown to an even
larger 1255 pages, and now covers Python 2.0. A lot of new
material is in it, but the same strategy of building up
examples is used. Mark Lutz' writing continues to be clear and
informative, and his examples well written. Programming
Python is more of a very thorough course in Python than it
is a reference one returns to. There is an adequate index, and
it is not unduly difficult to find things. But the book's main point
is to walk the reader through aspects of programming in Python.
The second option for a complete reference to Python is called,
straightforwardly enough,
Python: The Complete Reference
, by
Martin Brown. As in Python Annotated Archives, Brown has a
habit of interspersing short snippets of source code with prose
describing the code (this time with a distracting dark gray bar
to the left of the code). I do not really like that
style, but most of the sins of the other book are absent from
this one. The Complete Reference covers pretty much the same
ground as Programming Python; both are more about teaching
Python (to a programmer experienced in other languages) than
they are about serving as a reference. But The Complete
Reference has its material divided into 27 well-chosen
chapters, with both a detailed TOC and a good index. You may
not be able to turn to the exact page that answers your
question (as you can in Python Essential Reference), but at
least you can easily find the right chapter to read. At a bit
under 700 pages, reading 1/27th of the book to brush up on a
topic is a reasonable task. The prose is also better organized
and better written than Brown's other title.
In the "complete reference" category, I like the
Python 2.1
Bible
the best. If nothing else, it is more up-to-date in
terms of Python version than the other options. But even
beyond that, it is a nicer book for the particular slant. In
the Hungry Minds tradition, the book is a bit too "loud"
typographically -- I can hardly focus on the cover without
getting dizzy, and the text is littered with a few too many
icons, tables, dingbats, and the like. That said, I find the
bright sans-serif header font and vertical white spacing to be
very attractive; and the clean gothic fixed font makes for much
more easily scanned source code samples than does the courier
most books use. And even the judicious use of 10% screens
draws the eye helpfully.
Aside from the (important) physical appearance of Python 2.1
Bible, the organization is the most useful for programmers
with a bit of experience (the first few chapters develop the
necessary basic concepts pretty well). The book is broken into
more chapters (38), and the chapters are better focused on the
most important Python concepts than are the other "big" books.
Moreover, the TOC and index are both of extremely good detail
and quality. Brueck and Tanner's prose is furthermore the best
in this category of books -- factual, accurate, and to the point
(Lutz, and especially Brown, tend towards "chatty").
Resources - Read the previous installments of Charming Python.
- Read David's previous Python book reviews on developerWorks.
- To get started learning Python, head over to the Python documentation at Python.org.
-
Python & XML, Christopher A. Jones & Fred L. Drake, Jr.,
O'Reilly 2001 (est). ISBN: 0-596-00128-2.
- Visit Bruce Eckel's "Thinking in Python" Web site.
-
Python Essential Reference, Second Edition, David M. Beazley,
New Riders 2001. ISBN: 0-7357-1091-0.
-
Python Standard Library, Fredrik Lundh, O'Reilly 2001. ISBN:
0-596-00096-0.
-
Learn to Program Using Python: A Tutorial for Hobbyists,
Self-Starters, and Those Who Want to Learn the Art of
Programming, Alan Gauld, Addison-Wesley 2001. ISBN:
0-2017-0938-4.
-
Python: Annotated Archives, Martin C. Brown, Osborne/
McGraw-Hill 2000. ISBN: 0-07-212104-1.
-
Programming With Python, Tim Altom, Premier Press 1999.
ISBN: 0-7615-2334-0.
-
Programming Python, Second Edition, Mark Lutz, O'Reilly 2001.
ISBN: 0-596-00085-5.
-
Python: The Complete Reference, Martin C. Brown, Osborne/
McGraw-Hill 2001. ISBN: 0-07-212718-X.
-
Python 2.1 Bible, David Brueck, Stephen Tanner, Hungry Minds
2001. ISBN: 0-7645-4807-7.
- Browse more Linux resources on developerWorks.
- Browse more Open source resources on developerWorks.
About the author  | 
|  |
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.
|
Rate this page
|  |