Beazley, D. (2001) Python Essential Reference, New Riders.

Beazley's Python Essential Reference, second edition, claims to be the definitive guide to the Python programming language. Given the size of the language and the rather manageable size of the paperback, that seemed quite a claim but, as someone who has being "getting around to examining Python properly" for too long, it was precisely the sort of thing that I was looking for to quickly lead me into use of the language.

Despite the title, this is more than just a reference book; the first hundred pages are a brisk but (seemingly) complete introduction to the core Python language with the rest of the book a reference to many of the main libraries available. As such, this book will suit those who have a reasonable grasp of programming through other languages and want a quick conversion course to Python. This fills a nice niche in the market for those looking for a more thorough treatment of the subject than books such as Learning Python, who also want a bit of detail as you'll find in Programming Python but who don't want the verbosity (or the weight) of the hefty >1200 page tome!

The book could be considered as split into three sections:

(A full list of chapter headings is given at the end of the review).

Each chapter is split into what could be considered self assessment exercises, helping you to check you've understood that specific area. These explore a clearly defined chunk of the material from its chapter, describing the behaviour of the language features, giving examples and identifying pitfalls (particularly where the behaviour is potentially non-intuitive). In general, the layout is clear and the examples get to the heart of the issue at hand. That said, some sections appear disconnected from the general flow of the chapter and (for at least one of the chapters) a second (or third) reading may be required to get the full benefit.

The main section in the book, however, is Appendix A; The Python Library. This details the main libraries and classes provided with Python. The library is split into convenient sections (OS Services, Mathematics, Network Programming) and then broken down to more specific topics. The index at the back is excellent and, as a reference, it is laid out very clearly. If there were a criticism of this main section, it is that it more a list of pointers to the classes rather than real information about them. Given the cost in size (many other Python books that cover much less are much bigger) and that Python offers excellent on-line assistance for classes once you have found them, this is not necessarily a bad thing.

Just when you thought there was nothing left to shoe-horn into this book, you come across appendix B. This is Extending and Embedding Python, and not a surprising inclusion since Beazley is the developer of SWIG, a a package which helps tie C with interpretted languages (such as Python, Perl and Tcl). If you want some Python functionality within a C program or you'd like to embed some C into a Python program, look no further. Beazley introduces the C API for Python and describes how to use it with some simple examples and references for the whole API.

Conclusion

While the book is relatively svelte, it doesn't skimp on detail. This economy in size, however, comes at a price; there is no page wasted and the examples are not verbose. Where many larger books would be tempted to put an example for every feature, for example, Beazley has chosen instead to expose the use of certain features and allow the user to extrapolate from that to work out related functionality.

I personally found The C Programming Language (K&R) by Bryan W. Kernighan and Dennis M. Ritchie and Programming Perl (the Camel Book) by Larry Wall and Randal L. Schwartz indispensible when learning C and Perl respectively, and this book reminds me (in different ways) of each of those books. It is more expansive than K&R, and has fewer real-life examples than the Camel Book, but it covers what you need to know, it's concise without missing detail and, unlike many of its competitors, doesn't give you a hernia when you pick it up.

This book is probably not the one book a Python beginner should choose unless they have reasonable experience in similar languages. As a reference for someone improving their Python or converting from, say, Perl, it's an excellent buy and is likely to get good use.

The Chapters

The chapters of the book are reproduced below with their page ranges.

  1. A Tutorial Introduction (1)
  2. Lexical Conventions and Syntax (13)
  3. Types and Objects (19)
  4. Operators and Expressions (43)
  5. Control Flow (55)
  6. Functions and Functional Programming (63)
  7. Classes and Object-Oriented Programming (71)
  8. Modules and Packages (77)
  9. Input and Output (83)
  10. Execution Environment (93)
  1. The Python Library (99)
  2. Extending and Embedding Python (297)
  3. Summary of Changes (331)