Book Review: Python Standard Library
When I offered to review Python Standard Library, I expected to find a dull list of library functions with dry descriptions of their arguments. I was pleasantly surprised, though, when I started reading the book. The author claims to spend hundreds of hours answering questions on the comp.lang.python Usenet newsgroup. It shows.
Rather than the dry manual I expected, this book is filled with useful examples. It is comprehensive, with the exception of not covering Tkinter. This seems like a reasonable decision considering that the majority of Python users will not use Tkinter, and it would take a lot of space to document. In fact, Fredrik is working on a separate book on Tkinter.
Python Standard Library is divided into 14 chapters, each covering a related set of modules. As the book is comprehensive there is no reason to enumerate its contents here, but the divisions are quite logical. For example, there are chapters on threads and processes as well as mail and news message processing. Two chapters, "Platform-Specific Modules" and "Implementation Support Modules", cover the non-generic modules.
To give you a feeling for the book, I will describe two specific sections in detail.
The first section is called "The string Module", from the "Core Modules" chapter. This section is a little under two pages, the majority of which is code. After a once-sentence description, you are presented with an example. The example includes the file name (so you can find it on the CD), about ten lines of code and the result of executing the code. The code is mainly print statements with a text string passed to the various functions of string, e.g., string.upper, string.lower, string.split, string.count.
Next comes a brief description of differences between Python 1.5.2 and later versions. As the main difference is the availability of string methods in the later versions of Python, a new example is included that shows the same code written to use string methods instead of string module functions.
A third description and example explains the additional capabilities of the string module for converting other data types to strings. The final paragraphs describe how you can use the int and float functions as an alternative to the string module counterparts.
As a second example, I have selected "The cgi Modules" from the "Network Protocols" chapter. This description is about 1.5 pages long and includes two short paragraphs of text, followed by a listing. The listing is a CGI script that returns a list of files in a specified directory. It uses os.environ.get to grab the QUERY_STRING, os.listdir to get the file names and cgi.escape to clean up strings.
While the example is cleanly written and does what it says it should, I was a little disappointed that it did not go into all the functionality of the cgi module. For example, it mentions that the module can parse CGI form data, but there is no description or example of how to do this.
The CD is a logical addition, it includes all the scripts found in the book. In addition, it contains prebuilt Python 2.0 distributions for Windows and x86 Linux (in RPM format), plus a demo copy of PythonWorks Pro 1.2 for the same two platforms.
PythonWorks is an integrated development environment (IDE) for Python. The included software runs in demo mode, limiting what you can do with the included projects. However, you can get a free, time-limited Evaluation Ticket from the Pythonware web site, so you can see how it runs on your project.
Overall, the book is packed with a lot of practical information. The text seems accurate--the only typo I found was grammatical and insignificant. It doesn't answer every question readers might have, but for its size and readability it does a good job. Unlike some books I have seen on other programming languages--where readers are handed a lot of code but figuring out what it does and what it is related to is left to them--I found all the examples in this book relevant to the subjects being addressed.
As long as you don't expect to find everything in one book, I expect you will be satisfied. If, however, you just must have all the information in one book, the Python Developer's Handbook (reviewed in the February 2001 issue of Linux Journal) may be the better choice.
Phil Hughes is the publisher of Linux Journal.
|Natalie Rusk's Scratch Coding Cards (No Starch Press)||Feb 17, 2017|
|Own Your DNS Data||Feb 16, 2017|
|IGEL Universal Desktop Converter||Feb 15, 2017|
|Simple Server Hardening||Feb 14, 2017|
|Server Technology's HDOT Alt-Phase Switched POPS PDU||Feb 13, 2017|
|Bash Shell Script: Building a Better March Madness Bracket||Feb 09, 2017|
- Own Your DNS Data
- Simple Server Hardening
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- Understanding Firewalld in Multi-Zone Configurations
- From vs. to + for Microsoft and Linux
- Bash Shell Script: Building a Better March Madness Bracket
- The Weather Outside Is Frightful (Or Is It?)
- IGEL Universal Desktop Converter
- Server Technology's HDOT Alt-Phase Switched POPS PDU
- Natalie Rusk's Scratch Coding Cards (No Starch Press)