First, a confession. My favorite book for learning Python is Head First Python by Paul Barry. It literally does throw you head-first into Python programming. By page 10, it has you working with nested lists. By page 30, you are creating a function that you will save and turn into a module just a few pages later. By the time you hit page 50, you have learned how to upload code to PyPi. And, as the book continues, you keep improving and expanding the functionality of one project that stays in development from chapter to chapter.
That said, I hereby declare that Think Python by Allen B. Downey is my new co-favorite book for learning Python. I intend to keep it handy right alongside Head First Python.
Just about anyone studying or using Python can benefit from having Think Python on their bookshelf, in their computer, on their mobile device or, better yet, accessible in all these places. It is an excellent reference book, as well as a clear, concise and calm how-to guide for beginning programmers.
Think Python takes a gentle yet effective approach to introducing and exploring the language one step at a time. First you learn some basic programming concepts. Then, 13 pages in, you start easing into the language at the level of “Hello, World!”, plus variables, expressions, and statements.
The 277-page book has 19 chapters that carefully explain and illustrate each key point, without overkill. The author is a veteran instructor of computer languages, and he also is the author of a well-known book that has been around since 1999, in one form or another: How to Think Like a Computer Scientist.
Think Python is an outgrowth of the Python version that book. Downey has added materials on debugging and other topics, plus some exercises and case studies. And he has gotten plenty of proofreading help from more than 100 enthusiastic followers of his writings and teaching.
What I like most about Think Python are its short, concise, clear explanations of each new concept and its use of very short code examples. When I’m in the mood to spend just a few minutes reviewing or learning a new concept in Python, I can open Think Python and quickly find a refresher or a new area to try out. Head First Python, on the other hand, suits me best when I have an hour or two to stay focused on reading, keying in a lot more code and making the required changes to the ongoing project.
One minor caution: There are differences – sometimes significant and sometimes merely irritating – between Python 3 and Python 2. Head First Python focuses on Python 3 code and Think Python uses Python 2 code examples. But Think Python’s author has been careful to minimize the conflict and explains what to do when using Python 3.
The main thing to remember is that the print statement in Python 2 has become print(), a function, in Python 3. So if, for example, the book’s code says print ‘Hello, World!’ and you are using Python 3, you type print(‘Hello, World!’), instead.
It’s not hard. But the opportunity to print or print() something does come up a lot in the text.
— Si Dunn