About This Fifth Edition

The prior fourth edition of this book published in 2009 covered Python versions 2.6 and 3.0.[1] It addressed the many and sometimes incompatible changes introduced in the Python 3.X line in general. It also introduced a new OOP tutorial, and new chapters on advanced topics such as Unicode text, decorators, and metaclasses, derived from both the live classes I teach and evolution in Python “best practice.”

This fifth edition completed in 2013 is a revision of the prior, updated to cover both Python 3.3 and 2.7, the current latest releases in the 3.X and 2.X lines. It incorporates all language changes introduced in each line since the prior edition was published, and has been polished throughout to update and sharpen its presentation. Specifically:

This edition also adds a new conclusion as Chapter 41 (on Python’s evolution), two new appendixes (on recent Python changes and the new Windows launcher), and one new chapter (on benchmarking: an expanded version of the former code timing example). See Appendix C for a concise summary of Python changes between the prior edition and this one, as well as links to their coverage in the book. This appendix also summarizes initial differences between 2.X and 3.X in general that were first addressed in the prior edition, though some, such as new-style classes, span versions and simply become mandated in 3.X (more on what the X’s mean in a moment).

Per the last bullet in the preceding list, this edition has also experienced some growth because it gives fuller coverage to more advanced language features—which many of us have tried very hard to ignore as optional for the last decade, but which have now grown more common in Python code. As we’ll see, these tools make Python more powerful, but also raise the bar for newcomers, and may shift Python’s scope and definition. Because you might encounter any of these, this book covers them head-on, instead of pretending they do not exist.

Despite the updates, this edition retains most of the structure and content of the prior edition, and is still designed to be a comprehensive learning resource for both the 2.X and 3.X Python lines. While it is primarily focused on users of Python 3.3 and 2.7—the latest in the 3.X line and the likely last in the 2.X line—its historical perspective also makes it relevant to older Pythons that still see regular use today.

Though it’s impossible to predict the future, this book stresses fundamentals that have been valid for nearly two decades, and will likely apply to future Pythons too. As usual, I’ll be posting Python updates that impact this book at the book’s website described ahead. The “What’s New” documents in Python’s manuals set can also serve to fill in the gaps as Python surely evolves after this book is published.



[1] And 2007’s short-lived third edition covered Python 2.5, and its simpler—and shorter—single-line Python world. See http://www.rmi.net/~lutz for more on this book’s history. Over the years, this book has grown in size and complexity in direct proportion to Python’s own growth. Per Appendix C, Python 3.0 alone introduced 27 additions and 57 changes in the language that found their way into this book, and Python 3.3 continues this trend. Today’s Python programmer faces two incompatible lines, three major paradigms, a plethora of advanced tools, and a blizzard of feature redundancy—most of which do not divide neatly between the 2.X and 3.X lines. That’s not as daunting as it may sound (many tools are variations on a theme), but all are fair game in an inclusive, comprehensive Python text.