Python is the core programming language used at Parse.ly. It also happens to be a quickly-growing language with wide adoption among open source projects. It’s no wonder it’s quickly becoming the leading language for software teams.
I’ve written a couple of blog posts with original material for learning Python, including “import this: learning the Zen of Python with code and slides” and “Build a web app fast”.
Newcomers to Python are often overwhelmed by the wealth of information, available online and in print, for the language. I am often asked by others, “What are the best books for my Python team?” I plan to answer that question with this post, by highlighting what I consider to be the three best Python books on the market today.
Python Essential Reference
The best all-around book for Python is Python Essential Reference, 4th Edition, by David Beazley.
This edition of the book was published in 2009, at basically the perfect time — just as Python 2.7 had fully stabilized and work on Python 3 began. Python 2.7 is still the most widely used version of Python, so if you are a newcomer to the language, you won’t be missing anything by focusing on this version of the language.
The author, David Beazley, is a bit of a Python celebrity. He has given several highly-referenced PyCon talks, including some detailed discussions of generators, coroutines and the Python Global Interpreter Lock (GIL). He regularly teaches advanced Python courses from his office in Chicago. And he has a clear writing style, honed over years of experience.
The second part of the book is where the title comes from — it’s essentially a reference to the Python Standard Library.
It walks through all of the most important standard library modules, and illustrates each with examples. This section is, honestly, not meant to be read in chapter order. It’s meant to be skimmed and dipped into, depending on what kind of programming you’re actually doing. In a way, I wish this part was spun out into a separate book, because I think the overall book’s ~700 pages seem unapproachable to many, even though the most important part of this book, the first one, is only 200 pages.
Once you understand the basics of a programming language, your next level of mastery is to understand its idioms and best practices. This is where the next book, Fluent Python, comes in.
This book is a newcomer to the Python scene, and is authored by Luciano Ramalho. It was published in 2015.
Fluent Python tries its hardest to distill what it means to be “Pythonic” into a book. In a past blog post, I wrote that “Pythonic” means idiomatic and tasteful, and I tried to illustrate that concept with a small example. This book will try to actually get you to “see the light” and write Python in an idiomatic and tasteful way, even while teaching you the basics, and the advanced internals, of the language.
I was particularly impressed with this book’s discussion of Python’s data structures, which is supplemented with an overview of their internal implementation. The second half of the book goes into more depth on several topics than any other book on the market: things like iterators, generators, decorators, coroutines, descriptors, and class metaprogramming. I also found some of the historical discussion included in sidebars to be illuminating. This is a book I even recommend to Python old-timers.
I have to admit that I learned Python before many great print books were available for the language. I first learned Python in 2000, after reading Eric S. Raymond’s Linux Journal article, “Why Python?”. But one of the places I learned Python really well was via the early ActiveState Python Recipes website.
Though this website is still around (and somewhat active), the Python web community is much more diverse today; you can find tons of blog posts, recorded conference presentations, Stack Overflow posts, as well as print/digital books all over the place. But in the 2000-2002 period, ActiveState’s Python Recipes website was basically “it” in terms of learning advanced concepts for Python.
In fact, if you want to really challenge yourself in Python, you should read through all of Raymond Hettinger’s recipes. Many of the standard library’s most popular modules started as recipes on this site, such as namedtuple and Counter!
Anyway, the reason I am mentioning the Python recipes website is because in 2002, O’Reilly published many of the most popular ActiveState recipes into the book, Python Cookbook, which was edited by Alex Martelli, one of the circa-2002 Python community luminaries.
In addition to the code recipes themselves, Martelli provided some excellent commentary on why each recipe was necessary, what Python features it leveraged, and how it might be applicable to your own code. This book was basically my bible as I was developing with Python in the 2004-2008 period, when I started to apply Python to real software problems at scale.
By 2012, however, this book was already over a decade old, and showing its age. Luckily, none other than the heroic David Beazley decided to team up with Brian K. Jones and revitalize the title to publish a 3rd Edition. It went to press in May 2013. This book was re-thought from the 2nd edition from the ground up. It no longer relied exclusively on ActiveState recipes as a starting point, and was instead a more general “cookbook” approach to learning a modern and idiomatic version of the language.
What’s more, Beazley decided to focus his cookbook examples exclusively on Python 3 (specifically, Python 3.3, the latest version as of the time of publication). This means it’s the perfect third book to read, after Python Essential Reference and Fluent Python. Not only will it cover more advanced recipes, but it’ll cover them while also highlighting features from the newest version of the language, Python 3.
One tip: despite its age, I think the 2nd edition of Python Cookbook included some pretty sage explanations of Python internals by Alex Martelli, and these were pretty much entirely edited out of the new version of the book. Therefore, if you want bonus points, also pick up a used copy of the 2nd edition of this title for historical value!
It’ll also be fun to see how Python (the language, and the community) evolved over the last decade. By the way, Alex Martelli’s “Python in a Nutshell” 2nd edition is also a great book, and has some wonderful sections on Python’s data model, dunder methods, and object oriented programming “Pythonista style”, but at this point some of the core reference material in it is dated enough that I can’t still recommend the book as anything but a historical artifact.
A Certified Pythonista
So, that’s it — these are the 3 titles I recommend for Python software teams.
Python expertise awaits. Whether you are a pair of hackers building a prototype for a new startup; a 20-person team that is doing large-scale engineering with Python; or a thousand-person engineering department that is switching from Java/C++, your team will benefit greatly from copies of each of these!
- Python Essential Reference, 4e (Beazley)
- Fluent Python, 1e (Ramalho)
- Python Cookbook, 3e (Beazley, Jones)
You’ll all be certified Pythonistas in no time. Welcome to the community, and Happy Hacking!
p.s. you might be wondering, on what basis am I making these recommendations? Well, I’ve read a lot of Python books over the years.
Here are some “additional readings” — books I’ve read cover-to-cover, think are quite good, but wouldn’t put in my top 3 selections:
- Dive Into Python
- Natural Language Processing with Python
- Python for Data Analysis
- Think Stats
- The Python Standard Library by Example
- Python in a Nutshell
- The Definitive Guide to Django
- Introduction to Tornado
Here are some other Python books I’ve read cover-to-cover, which are OK and may be worth a skim, but not on a “greatest hits” list:
- Learning Python
- A Byte of Python
- Python Pocket Reference
- Think Python
- Learn Python the Hard Way
- High Performance Python
- The Quick Python Book
- Programming in Python 3
- Practical Programming (with Python)
- Python and AWS Cookbook
- Instant Flask Web Development
- Pro Django
Many of these are good books, but the 3 recommended in this article are the best for learning the language overall, in my opinion.
Books referenced and reviewed: Python Essential Reference, 4e, Addison-Wessley; Fluent Python, O’Reilly; Python Cookbook (2e and 3e), O’Reilly. NOTE: The book links, when they linked to Amazon.com, included an affiliate tracking code.