What books to read to master basic Python skills
In my fifteen years as a Python developer and author, one question seems to come up over and over again: “Can anyone recommend a good book on Python?” To book authors, this is pretty much a conflict-of-interest question. “Why, mine!” is what we would all say.
The problem is that there is no correct answer. The right answer depends on the reader’s level and skillset, as well as the style of learning that they find most compatible. This means the best book is different for different people. As lofty as it may sound, my main goal is the good of the community. If my book is the right one for certain classes of users, that’s great. If not, I’m happy to recommend others which may be a better fit.
Before we get started, I’ve have one comment on another popular question: Python 2 or Python 3? While Python 3 has been around for more than 3 years, many libraries and packages have been ported, and a new 3.3 release forthcoming late summer, most of the world still runs on Python 2. If you have no old software to port and are getting into Python now, you can start with 3.x. If you have existing code that still runs under 2.x, start there, because the changes are mostly cosmetic (albeit backwards-incompatible). Once you learn one, you can get up-to-speed with the other quickly. Now let’s get reading!
In this article, I’ll go over three different reading lists for three different audiences. The first audience is existing programmers who need to learn Python.
For Programmers New to Python
- Dive into Python 3 by Mark Pilgrim, Apress
- Core Python Programming by Wesley Chun, Prentice Hall
- The Quick Python Book by Vern Ceder, Manning
- Beginning Python: From Novice to Professional by Magnus Lie Hetland, Apress
- Learn Python the Hard Way by Zed Shaw
Dive into Python 3 by Mark Pilgrim, Apress, 2004, 2009
One of the most popular Python books has been Dive into Python. Originally published in 2004, a new version for Python 3 was published in 2009. For developers who prefer to learn by just diving into code, this is one of your top choices, even more so since the author is one of my co-workers! However, if you prefer to learn a lot more before venturing into programming, there are other options for you..
Core Python Programming by Wesley Chun, Prentice Hall, 2006
Core Python Programming is pretty much the opposite of Dive into Python. Instead of a “quick dive,” I would call it a deep dive into the Python language. The goal of this book is to teach you Python as quickly but as comprehensively as possible. There are plenty of code samples to look at and try during your reading, so you don’t have to read that much before getting started. Even better are the exercises at the end of every chapter to help you put what you learned into practice. Furthermore, a healthy dose of charts and tables provides reference material for readers. In 2009, I added two new appendices on Python 2.6 (also applicable for 2.7) and 3.x to keep the book contemporary. These appendices are available in the 5th and newer printings. All other readers can download both appendices as well as a cleaned up index on the book’s Web site at corepython.com.
The Quick Python Book second edition by Vern Ceder, Manning, 2010
The Quick Python Book is similar to Dive into Python, but originally published well before the latter except that it goes into a bit more detail than Dive. Its reviews are just as good as its newer brother. A few years ago, it was updated to Python 3.
Beginning Python: From Novice to Professional second edition by Magnus Lie Hetland, Apress, 2008
The Beginning Python book also goes more into detail than Apress' fellow book, Dive into Python. It is very readable and user-friendly; however, like the Quick Python Book, it doesn’t dive in as deeply as Core Python Programming. It’s just right in the middle and thus could be your cup of tea. There’s even a companion Web site for the book.
Learn Python the Hard Way second edition by Zed Shaw, 2011
This self-published series takes a completely different approach: the author forces you to code and code correctly, then explains what you did and why. But since you already had to experience it, you pick up programming skills more quickly. This book is also suitable for those who have never programmed before, and is “brutally-friendly” for these readers.
For Kids and Other Complete Beginners
This is where our next list comes in: a list of Python books for those who have never programmed before, including children; hence the name of the list.
- Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande, Manning,
- Invent your Own Computer Games with Python second edition by Al Sweigart
- Python for Software Design: How to Think Like a Computer Scientist by Allen B. Downey, Jeff Elkner and Chris Meyers, Green Tea Press
- Python Programming for the Absolute Beginner by Michael Dawson, Course Technology
These four books are often used to teach children how to program because they involve using Python to write game programs. What could be more fun than that?
Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande, Manning, 2009
One of the top-selling child-friendly books is written by an engineer and his (then) 8-year old son, so the writing also contains dialog from a kid’s perspective. The juxtaposition of these differing dialogs and perspectives makes for family-friendly reading.
Invent your Own Computer Games with Python second edition by Al Sweigart, 2010
Another beginner book with great reviews is Invent your Own Computer Games with Python. Like Hello World!, you learn to code by writing games, but the book also assumes readers have absolutely no programming experience whatsoever and walks them through the concepts as well as building games.
Python for Software Design: How to Think Like a Computer Scientist by Allen B. Downey, Jeff Elkner and Chris Meyers, Green Tea Press, 2002
This book is one of the classics. Originally created for C++, it was ported to Java, then Python. While the first books in the list are great for upper elementary and junior high age on average, this book is geared toward teenagers in high school or non-science/engineering collegiate students. In addition to learning programming, readers will also pick up concepts from the study of Computer Science.
Python Programming for the Absolute Beginner by Michael Dawson, Course Technology, 2010
The last one in this list is the original newbie book. It teaches readers to code by writing games. It has remained fairly popular, as there wasn’t anything like it when it was first published. It still gets good reviews, even the latest edition that’s been revised to Python 3.
References
The final list of books to look at are the references–those companion tomes that you should also have on your shelf. The best ones are those that you can just pull off the shelf, look up something, then put away.
- Python Essential Reference fourth edition by David Beazley, Addison-Wesley
- Python in a Nutshell second edition by Alex Martelli, O’Reilly
- Python Cookbook second edition by Alex Martelli, Anna Ravenscroft, David Ascher, O’Reilly
- Python Standard Library by Example by Doug Hellmann, Addison-Wesley
Python Essential Reference fourth edition by David Beazley, Addison-Wesley, 2009
The first book in this list is the classic “PER” (Python Essential Reference). It was the very first one (at least its original edition was). Back in the Python 1.5 days, the only real reference Python programmers had was the Standard Library Reference online documentation. Printing it out was enormous: about an inch thick double-sided! Developers craved a “library reference to take home.” Python Essential Reference alleviated that need and represented exactly that: a small, portable version of the library reference. It has since been updated regularly by jazz musician and mad (computer) scientist, David Beazley.
Python in a Nutshell second edition by Alex Martelli, O’Reilly, 2006
Several years later, a second reference book came out, this one from O’Reilly as part of their classic Nutshell reference series written by the incomparable Alex Martelli, another co-worker of mine. Both the Nutshell and PER references are written by luminaries in the Python world, and both books are similar. The best suggestion I can offer you is to flip through several pages of both and find which writing style suits you best.
Python Cookbook second edition by Alex Martelli, Anna Ravenscroft, David Ascher, O’Reilly, 2005
The final two books are not references as much as the first two, but they are still references to consider if you want to go beyond the pure lookup reference guides. This book is based on the online Python Cookbook, a series of “recipes” that are Python snippets of code that “do something.” You can find all the recipes here at http://code.activestate.com/recipes/langs/python, but the book contains “the best” ones, plus additional commentary by the editors. A new version is forthcoming as well.
Python Standard Library by Example by Doug Hellmann, Addison-Wesley, 2011
If you can imagine one of the earlier references along with many more code samples, you’ll arrive here. Rather than covering every single module and package in the standard library, this book takes the most popular ones that are used by developera today. It is based on the popular blog series, PyMotW (Python Module of the Week), maintained by the author himself.
The Next Step
What do you do after you’ve learned Python? You may have read my book or others like Dive into Python, Beginning Python, or Learning Python and have written some basic tools/apps. However, to go to the next level, you have nowhere to turn other than dive deeply into specific topics with books about game programming, databases, graphics/multimedia, GUIs, scientific programming, networking, etc.
There are definitely books on advanced topics such as these and more, don’t get me wrong. But if you want to develop more than one of these skills, you’d have to buy a book on every topic of interest. This is overkill, especially if you’re only looking to expand your skillset. In that case, you’ll want to reach for this book:
Core Python Applications Programming by Wesley Chun, Prentice Hall, 2012
Those of you who have read Core Python Programming will recognize much of the material in this book, because it comes from Part II of Core Python Programming. In the original book, I felt I had done a good enough job of teaching Python to readers, but didn’t have the room to get into any details about what you could build with it. Now that that material has expanded beyond the borders of an introductory book, it was time to split out this intermediate/advanced material into its own volume.
Thus I am pleased to announce that those chapters have been extracted to form their own book, Core Python Applications Programming! The contents have been cleaned up and retrofitted with Python 3 examples paired w/their 2.x friends as a hybrid to help you learn both 2.x & 3.x. There is plenty of new material added to existing chapters, as well as completely brand new ones on Web framework development using Django, an introduction to cloud computing with Google App Engine, and text processing with CSV, JSON, and XML. The purpose is to provide comprehensive introductions to each of these areas of application development, hence the title. I hope you are as excited about the new book as I am!
Conclusion
Now that you’ve seen a variety of ways to address that question of which book with the possible correct answer, we hope that you’re able to use this article to get the right Python book(s) for you. While I hope you find that my books best fit your needs, I’m more happy that you get what you need to build great applications in Python. If you’re new to Python, welcome to our family!