Sunday, January 16, 2011

Book Review: Programming Python 4e by Mark Lutz

Programming PythonProgramming Python by Mark Lutz

My rating: 4 of 5 stars

I've been using Python since I was a graduate student. While I have known of earlier versions of this tome it had never occurred to me to go through this. Because my focus in computer programming is not in the systems administration or IT related skills like most of O'Reilly Press customers seem to be. My interest is in scientific programming and data analysis. Now that I have had some time and occasion to use this, I find that the content is indeed weighted at an audience whose function is computer programming (as opposed to using computers for something else), but what this book really provides is an education on how to accomplish tasks in idiomatic Python, not just a programming how-to book.

Programming Python (PP4E) goal is NOT to teach programming in the Python language (that task was for another book by Lutz, Learning Python). The stated goal was to teach practical use of Python, and that necessarily means using the standard libraries. But even at 1600+ pages you can't do everything. So this book focuses on (IT) systems administration, GUI development and web programming using Python 3.x (not covering Python 2.x). None of these are what I do. But, there are some tasks that are covered that can be very useful, so in reviewing this book I focused on Graphic User Interface (GUI) and text processing.

What I found as I worked through these sections was that PP4E was not a reference as it lacks systematic coverage of topics. And it is not just a tutorial, although it definitely follows a crawl, walk, run sequence as it covers the topics. What it does do well is cover how to think and how to make design decisions. So for the GUI section it focuses on tkinter, and it does cover various widgets, window managers, etc., where it shows its colors is when it discusses how the parts work and how you make choices between alternatives (e.g. window managers). There are some warts with its focus on Python 3. There are several chapters in the GUI section that require the Python Imaging Library (PIL). But based on the PIL web page, PIL is not ported to Python 3.x. So it probably means that Lutz used a pre-release port without telling us.

Similarly, regular expressions is something I've never quite gotten. And I would not be able to master use of the re module here, since it lacks a usual lists of functions with examples that a reference or a tutorial would have. But what it does do is to cover how regular expressions fit along with other string operations, when and why to use match, search, find, findall, compile. When to compile and how to think through building a regular expression sequence. You would not learn how to use regular expressions here (I would never be able to develop the examples from what is in the book), but you will learn how to think through them, and bring that when you go back to a real reference or instructional book.

One aspect that is very annoying is the examples quickly become more complex than the material that leads up to it. So instead of crawl, walk, run; it takes on the feel of crawl - sprint, with a basic introduction then quickly moving into a complex and mature code. Some of this is a result of a goal of trying to be deep in everything. So be warned.

I received a free electronic copy of Programming Python from O'Reilly Press as part of their blogger review program.

I review for the O'Reilly Blogger Review Program
View all my reviews at Goodreads

No comments: