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.
|Free Today: September Issue of Linux Journal (Retail value: $5.99)||Sep 27, 2016|
|nginx||Sep 27, 2016|
|Epiq Solutions' Sidekiq M.2||Sep 26, 2016|
|Nativ Disc||Sep 23, 2016|
|Android Browser Security--What You Haven't Been Told||Sep 22, 2016|
|The Many Paths to a Solution||Sep 21, 2016|
- Android Browser Security--What You Haven't Been Told
- Readers' Choice Awards 2013
- Epiq Solutions' Sidekiq M.2
- Free Today: September Issue of Linux Journal (Retail value: $5.99)
- Nativ Disc
- The Many Paths to a Solution
- Synopsys' Coverity
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Returning Values from Bash Functions
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide