Most helpful positive review
63 of 63 people found the following review helpful
Probably the best "second book" on Python
on March 4, 2011
David Beazley's "Python Essential Reference, Fourth Edition" covers Python 2.6 and 3.0, and is thus quite (though not completely) up to date. The author has in essence chosen to present the intersection of the two branches, i.e. omit features of Python 2 that have been removed from Python 3. This volume's pace is rapid and the coverage is quite extensive, so this probably shouldn't be the first Python book one reads.
The Good: this book is approximately 700 pages long; even so, it's not that bulky and is therefore quite manageable. It is split into two parts: 200 pages on the language and roughly 400 pages on the library. The first part is very good, while the second part is unrivaled as of this writing (though this may change when Doug Hellmann's "The Python Standard Library by Example" comes out). Thus, the reader essentially gets two books for the price of one: the part on the language can be read linearly, while the library part can be read in chunks as the need arises. The book also includes an extremely useful Index which is approximately 80 pages long (and also contains unexpected entries, e.g. "chicken, multithreaded, 414"). Moving on to the material covered: Beazley includes an appendix on Python 3-specific concepts, but also offers useful advice on Python 3 throughout the main text (e.g. "To keep your brain from exploding, encoded byte strings and unencoded strings should never be mixed together in expressions"). I particularly enjoyed the sections on decorators, generators, and coroutines in the chapter on functional programming. Beazley has also posted on his website two tutorials on these topics that nicely complement the material in the book. Similarly, the chapter on multiprocessing and threading is impressive, and forms a nice set with the author's talk slides on the Global Interpreter Lock -- it's important to note that Beazley used to be a professor of Computer Science. Probably the most significant aspect of this book is the abundance of examples. I'm pretty sure the phrase that is most often repeated in this volume is "Here's an example". The examples are always enlightening, sometimes clever, but never obfuscating. Finally, the writing may not be flawless but overall it is quite good. Of course, any reference text is bound to be somewhat dry, but within the confines of the genre Beazley has truly done wonders: he has a personality and he's not afraid to show it. This jovial aspect of the writing is present when giving advice (e.g "Try not to mix threads and multiprocessing together in the same program unless you're vastly trying to improve your job security", p. 435), or just for its own sake (e.g. "If you change the code to only poll after every six-pack of beer", p. 469)
The Bad: chapter 1 is fun to read but it is deceptively titled ("A Tutorial Introduction"). For example, Beazley uses a decorator and the seek file method, without explaining anything about either of them. Of course, this book isn't supposed to be introductory, so strictly speaking my quibble is with the first chapter's title, not its content. The biggest problem I encountered while reading the book was the page layout in the majority of Part II: a module is introduced and then its methods are described by showing a name in bold, followed by a description on a separate line. This confused me to no end: whenever I saw a name, for a split second I would wonder if I should look up or down to find the description. This could have been avoided if the more standard tabular form had been chosen more often: name on one column, description on the other. Of course, I understand that this would have increased the size of the book considerably, perhaps prohibitively so. Moving on to more detailed complaints: for some modules (e.g. struct, shutil, os.path) Beazley gives a listing of the contents but, unfortunately, no corresponding examples. To be fair, he does use os.path functionality in a number of places throughout the book (though the index is no help tracking them down), just not in the appropriate section. Delving into even more detail: any book of this breadth is bound to contain minor errors. Here's a selection of such slips, all drawn from the same chapter: in some cases the prose is obscure, e.g. "A method is a function that performs some sort of operation on an object when the method is invoked as a function." (p. 33); sometimes a statement is contradicted in a later chapter, e.g. we read on p. 39 that "Sequences represent ordered sets of objects indexed by non-negative integers and include strings, lists, and tuples." only to find out on p. 68 that "Negative indices can be used to fetch characters from the end of a sequence."; similarly, on p. 45 we read that for dictionary methods like keys() "in Python 3 the result is an iterator that iterates over the current contents of the mapping", while on p. 632 we learn that "these methods return so-called view objects".
These days, the aspiring intermediate Python programmer doesn't have too many books to choose from: Martelli/Ravenscroft/Ascher's "Python Cookbook" is out of date, Ziade's "Expert Python Programming" contains too much material that is not Python-specific, and Alchin's "Pro Python" is only ~ 250 pages long. Thus, for the time being Beazley's "Python Essential Reference" is the obvious choice for a second book on Python. All in all, four and a half stars.