If you are learning Python, a beginner to intermediate Python programmer, you'll want to get a copy of this book. It won't do as your only Python book, but as a supplement to <i>Learning Python</i> or one of the other introductory Python books, it is invaluable for the non-expert Python programmer. If you bought the first edition of the book, which was available only as an eBook, you'll want this edition as it covers Python 2.0 as well as Python 1.5.2. (The eBook edition covered only Python 1.5.2.)
Each chapter begins with a brief summary of what will be covered. Chapter 4 is summarised as follows: "This chapter describes a number of modules that can be used to convert between Python objects and other data representations. These modules are often used to read and write foreign file formats and to store or transfer Python variables." It's terse, to be sure, but it's not meant for someone who has never looked at Python before.
Frederik assumes you know which module you want to use and gives you some sample code that shows you how to use it. You might ask on a newsgroup how to parse an HTML file. Someone will answer and tell you to look at either the htmllib or sgmllib module. Great. So, umm, how do you use them? A sample script showing you how to do something with either module or both could save you hours of frustration. Frederik also gives you tips on how best to use a module or when not to use it. For example, in describing the htmllib module, he says "If you're only out to parse an HTML file and not render it to an output device, it's usually easier to use the sgmllib module instead."
The book is sprinkled with tips. Early in Chapter 1 he points out that "What you might now know already is that import delegates the actual work to a built-in function called __import__. The trick is that you can call this function directly. This can be handy if you have the module name in a string variable, which imports all modules whose names end with '-plugin'."
The books covers: core modules (eg, re, time); more standard modules (eg, file input, md5); threads and processes (eg, thread, pipes); data representation (eg, pickle, base64); file formats (eg, xmllib, zipfile); mail and news message processing (eg, rfc822, mimetypes); network protocols (eg, socket, asyncore); internationalisation (eg, unicodedata); multimedia modules (eg, wave, winsound); data storage (eg, dbhash, gdbm); tools and utilities (eg, pdb, profile); platform-specific modules (eg, pwd, nt); implementation support modules (eg, macpath, ntpath); and other modules (eg, Bastion, calendar, posixfile, regsub).
The sample code is printed in Courier and some of the samples are tracked too tightly, making it difficult to read. I assume in production they applied the same tracking values for the body text to the code text. (Tracking is the spacing between a series of characters where kerning is the space between two characters.) But that happens only occasionally.
Also included with the book is a CD which contains copies of all the scripts plus an evaluation copy of PythonWorks Pro 1.2, a Python IDE for Windows, Linux, and Solaris. (Fredrik works for Secret Labs AB who develop PythonWorks.) I was able to browse and open the sample files on MacOS X. But of course I couldn't try the evaluation copies of PythonWorks. I would rather they had dropped the CD and made the sample scripts available as a download -- it would drop a few dollars off the cost of the book. If you're an expert Python programmer you won't need this book. But if you're a beginner to intermediate Python programmer you'll find the sample code and commentary invaluable when you try to implement an unfamiliar module, particularly some of the more complex ones. And the tips sprinkled throughout the text will help you achieve mastery of this most glorious of programming languages. Highly recommended.