Code and comments

Practical and theoretical aspects of software development

Book Review: Core Python Programming by Wesley Chun


If you are want to learn Python, and you like to learn from books, there is a clear consensus: Dive into Python. It’s available free online, so I gave it a try.

I didn’t like it. I felt bad for not liking it, after all, everyone agrees it’s a great book. Mark Pilgrim takes an interesting approach, diving in with real-world examples of what can be done with Python, rather than the typical approach of introducing the language systematically. But it just didn’t work for me. I found myself unmotivated by the examples, and bothered by the fundamental questions that hadn’t been answered. I had to look elsewhere.

Finding a reliable suggestion for an introductory Python text that isn’t Dive into Python isn’t easy, but John Cook recommended Core Python Programming(CPP) by Wesley Chun. I’ve agreed with John enough times that when it was time to actually learn Python, I bought Chun’s book.

This is an excellent book. It is well organized, thorough, and readable. I highly recommend it for any programmer that wants to learn Python, likes books, and prefers a systematic approach to a quick dive.

Chun is often compared to that of Bruce Eckel (Thinking in C++, Thinking in Java) for his thorough, readable explanations. It is a good comparison in terms of style, but it actually worried me, as I did not have the best experience with Thinking in Java. In my estimation, Chun is superior to Eckel in the following ways:

  1. Chun is thorough, but with the main point always in view. Eckel is too verbose.
  2. Chun’s code samples were practical, illustrative, and reasonably consise. Eckel’s code samples can be really large on occasions.
  3. I have never met him, but Eckel writes like a man who is a bit fascinated with himself, which is distracting. Chun’s writing never seems to draw attention to the author.

CPP is divided into two parts, “Core Python” and “Advanced Topics.” The first three chapters introduces Python, gives a tutorial, and covers some style and syntax issues. For the rest of Part I Chun discusses the standard language features in detail: data types and structures, conditionals and loops, file I/O, exceptions, functions, modules, objects, and more.

Many of these topics are reasonably covered in the standard tutorials, but the coverage here provides useful context. For example, to understand Python types and classes, it is very useful to understand the significant changes that occurred in Python 2.2 and 2.3. And the careful details of how Python implements OOP, resolved a host of subtle confusions I had about __init__(), self, and super, none of which are exactly analogous to anything in Java.

The second part includes a variety of that are extremely helpful, and often left out of an introductory core language book. There are chapters on regular expressions, network programming, internet client programming, multithreaded programming, gui programming, web programming, database programming, extending python, and a chapter on miscellaneous topics.

The highlight in this part for me was the chapter on database programming. It would have saved me hours if any of the books I read on Java had covered JDBC half as carefully as Chun covers DB-API, giving examples with multiple databases, and giving two examples with ORMs. Chun usefully introduces SQLite, a serverless relational database which is extremely useful for small applications or for testing. (It serves a role similar to HSQL in the Java world, but is much easier to use.)

Obviously, this book isn’t one you want if you don’t plan on learning much Python, or if you already have learned Python well. But if you have need of a thorough, detailed, programmers introduction to Python, you can hardly have a better experience than reading CPP by Chun.


Written by Eric Wilson

September 26, 2011 at 5:38 am

Posted in reviews

Tagged with ,

%d bloggers like this: