Sunday, August 23, 2009

Book Review: Python Essential Reference, Fourth Edition



Disclosure: I received a copy of this book for free from Addison-Wesley as part of the PyATL Book Club.

I have a copy of the first edition of the Python Essential Reference that I picked up at IPC 8 back in 2000. It's largely out of date by now, given that it covered Python 1.5.2. But at the time it was one of the few books I always kept close at hand for easy reference. Over time my reference habits evolved away from paper references in favor of online materials. Today I cleared a little space on my desk for the fourth edition of PER by David Beazley, updated to cover Python 2.6 and 3.0.

Pound for pound:

Just a little space, mind you, because the book is quite compact (717 pages in 6" x 9" x 1", easily portable in a backpack or briefcase). This book, diminutive though it may be, has more information of direct use to Python programmers than many of the War and Peace-sized tomes you'll find elsewhere. If David keeps adding material at this rate, I'm going to need a magnifying glass for the next edition.

The book is organized into three main sections: Language, Library, and Extending and Embedding. There is a comprehensive index and the chapter sequence places related information close together. You will not find yourself flipping back and forth between an early "prose" chapter to a later "reference" section.

Language:

The language section can serve as a reference guide for Python, though I think the first chapter title "Tutorial" is a little optimistic based on the brevity. To be fair, the preface states right up front that the book is not intended to be an introductory text.

This is not a book for learning Python. It is a book for writing Python.


Library:

The coverage of the standard library is where PER really shines. I have a certain amount of interest in documenting the Python standard library myself, so I was especially keen to review the material here. I found it up to date, clearly explained, and detailed. There is not a lot of sample code, but it is not entirely devoid of examples. In most cases, the prose descriptions are sufficient and eliminating code samples let David maintain a readable style without adding filler material.

I thought I had internalized most of this material long ago, but I learned a few things by re-reading it.


As the title implies, this is not an exhaustive reference guide. It covers the essential information that will be useful to the most readers. As a result, some of the modules are covered in less depth than others. However, I tend to agree with where focus is placed. For example, much more space is given to working with sqlite3 and databases in general than some of the more esoteric modules like dis. The ast module doesn't appear at all.

Extending and Embedding:

The Extending and Embedding section is one area where plenty of example code is provided. Three techniques for creating extension modules are covered: hand coding, ctypes, and SWIG (no surprise, since SWIG is popular and was written by the author). Examples and commentary are provided for all three approaches.

Going the other direction, embedding an interpreter in another application, is also explained. All of the functions from the Python library useful to someone trying to make their application scriptable are listed and described, with some basic examples showing how to communicate between the interpreter and your main application.

Recommendation:

Due to the reference style, this should not be your first Python book. It should absolutely be your second.

2 comments:

Irene Jennings said...

This book is awesome. Having struggled for the past couple of weeks with the NLTK and Python book, this book is a complete breath of fresh air.

Everything is here. It's laid out clearly. It's explained clearly. If you want or need to know it, it's in here and you'll be able to find it.

regrads,
irene of Dallas IT Consulting

Unknown said...

Did you hear there's a 12 word phrase you can say to your man... that will induce deep feelings of love and instinctual appeal to you buried within his heart?

That's because hidden in these 12 words is a "secret signal" that triggers a man's impulse to love, please and guard you with all his heart...

=====> 12 Words That Fuel A Man's Love Response

This impulse is so built-in to a man's brain that it will make him try better than before to love and admire you.

As a matter of fact, fueling this dominant impulse is absolutely essential to getting the best ever relationship with your man that once you send your man one of the "Secret Signals"...

...You'll instantly notice him open his mind and heart to you in such a way he never experienced before and he'll distinguish you as the one and only woman in the universe who has ever truly tempted him.