Book review: Think Python, First Edition, by Allen B. Downey

posted: October 11, 2015

tl;dr: Definitely recommended as a great way for experienced programmers to quickly learn Python, or as a textbook for a first college-level computer science course (or advanced high school).

The Python programming language has some excellent attributes that make it arguably the best language for spanning the immense range in abilities from an absolute beginner to a serious, professional programmer. For the beginner it is free (easily installable from; multi-platform (runs under Windows, Mac OS X, Linux, and a variety of other hardware devices and operating systems); interpreted (which avoids introducing the complexities of compilation); clean and clear in its syntax, with a minimal use of punctuation; and it allows the novice to progress from executing single statements to multi-line scripts to functions to classes and objects. For the experienced programmer it features a huge variety of easily accessible libraries, packages and development tools covering a wide range of applications (from scientific to data analysis to web development); it improves programmer productivity in comparison to other more syntactically challenging languages that expose more of the lower-level details; it produces more understandable, maintainable code; and it is becoming widely used as the top-level scripting language to stitch together other applications and software services into an overall top-level application.

Python is more and more the language of choice for instruction at the high school and early college levels. I believe that college computer science students are the primary audience that Allen B. Downey, a college computer science professor, was targeting with his book Think Python. The subtitle of the book is "How to Think Like a Computer Scientist", and besides discussing the basics of the Python language, his book also educates the reader/student on many essential computer science concepts: data isolation and scope, iteration, recursion, data structures, algorithms, refactoring, debugging, and graphical user interfaces. The book also touches upon some more advanced computer science topics such as cryptography, advanced mathematical calculations, textual analysis, Unified Modeling Language diagrams, and algorithm analysis. Each chapter of the book contains exercises to challenge the reader's understanding. These progress all the way from printing “Hello, World!” to the final exercise of writing a basic web browser. On his web site Downey includes his own answers to many of the exercises, and even an experienced Python programmer can pick up some tips on the language by examining Downey's code, which is very terse and shows a thorough understanding of the intricacies of Python and the best way to accomplish a given task.

For experienced programmers looking to learn Python, the computer science topics will serve as a refresher while learning the syntax and style of Python programming. Think Python covers all the major aspects of Python in an informative and concise way. Allen Downey's prose reminded me of that of Brian Kernighan and Dennis Ritchie in their seminal work The C Programming Language. Readers who enjoyed K&R should also enjoy Think Python. However, readers looking for a voluminous explanation of all aspects of Python should look elsewhere, as Downey does not attempt to rewrite all the help pages for Python. Nor does Downey cover all the advanced aspects of the language; lambda functions and decorators are two of the omitted topics. I also think that younger students, such as those in junior high, or high school students in their very first programming classes, could benefit from a book that provides more hand-holding and prose to explain the topics in a more gradual, gentler manner. But for advanced high school students and college students, Think Python would make a wonderful textbook.

My main criticism of the book, given that its primary audience consists of students, is that Downey used Python 2 rather than Python 3 throughout the book. The book was published in 2012, and the world was a slightly different place back then, but I think it would be best to start new students in the newer, slightly more structured variant of Python. The differences between the two are not great, which is all the more reason for Downey (or someone else – it wouldn't actually take too much work) to update the book to use Python 3 in the next edition.

Bottom line: I very much enjoyed Think Python and I recommend it if you fit the target audience.