I have always found it difficult to take seriously a language whose name is taken from the Monty Python’s Flying Circus shows. But Hetland has done a commendable job in helping me come to terms with this language’s capabilities. As an active member of the Python community, and author of the “Instant Python” online tutorial series, he is ideally qualified to write a book such as this.
The book is targeted at a wide audience. Neophyte programmers are encouraged to start at the beginning and progress through the chapters in sequence. Those who have done some programming are advised to skim through the early chapters, and/or skip to chapter 10, “Batteries Included,” which describes the Python shared libraries.
The first chapter guides the reader through acquisition and installation of the Python interpreter on the Windows, Linux, Unix, and Macintosh platforms. Several variations of a “Hello world” program are included, to illustrate assignment statements, variable types, and function usage. The example programs (along with all other programs in the book) are available from a Web site.
In chapters 2 through 4, the reader is introduced to sequences (namely, arrays as exemplified by lists, strings, and tuples) and to dictionaries (namely, associative arrays). The functions and methods that can be used on these to perform operations such as sorting are illustrated in some detail.
Chapter 5 is titled “Conditionals, Loops and Some Other Statements.” It offers some additional observations in relation to “print” and “import” statements, and introduces Python’s indentation-based block-definition scheme. Several loop mechanisms are presented, and the chapter ends with some comments on the “exec” and “eval” statements.
Introducing object-oriented concepts to those without previous exposure to this topic is a difficult task. The author does an excellent job in this regard in chapters 6, “Abstraction,” and 7, “More Abstraction.” Exceptions are covered in chapter 8, and “magic” methods associated with special names like “__init__” are illustrated in chapter 9.
The final three chapters in the first part of the book concern standard libraries, file access methods, and graphical user interfaces (GUIs). The last of these contains an editor program that makes use of the author’s “anygui” toolkit, and some programs that use toolkits for specific platforms (such as Jython).
The second part of the book occupies almost half of its pages, and provides some guidelines about program styles and development procedures, followed by a set of ten “projects.” Among these are a bulletin-board program that uses a structured query language (SQL) database, and a game program in which a player is, amusingly, required to manipulate a banana so that it doesn’t get squashed by a falling 16-ton weight. I was able to test several of the projects (using RedHat Linux 8.0). The only difficulty I encountered was in one that used the “anygui” toolkit; the author has advised that this is being addressed in a forthcoming release of that toolkit.
There is a language summary at the end of the book in Appendix A, followed by a “Python Reference” (somewhat more structured) in Appendix B, and a useful listing of online resources in Appendix C.
I have a couple of minor issues with the book. I would have liked to see some comments about why I might use Python instead of Perl or Java. And there are one or two places where the author’s enthusiasm in illustrating a clever construct gets in the way of understanding.
That said, I have to confess that I haven’t seen another introductory Python book that is as easy to read overall as this one, and I found the projects in the second half especially valuable.