PEP-0371 – Adding the processing module to the Python standard library

Jesse Noller is championing the addition of the processing module to the standard library. We’re making extensive use of processing at work now, so I can say it is an extremely simple API for spawning and managing tasks in the background. Passing data between processes using the processing library is as easy as with standard threads. As I have written before, I’m excited about this library and I’m looking forward to having it available everywhere without any extra effort on our part.

PyMOTW: contextlib

The contextlib module contains utilities for working with context managers and the with statement. Context managers are tied to the with statement. Since with is officially part of Python 2.6, you have to import it from __future__ before using contextlib in Python 2.5. Read more at pymotw.com: contextlib

PyMOTW: traceback

The traceback module works with the call stack to produce error messages. A traceback is a stack trace from the point of an exception handler down the call chain to the point where the exception was raised. You can also work with the current call stack up from the point of a call (and without the context of an error), which is useful for finding out the paths being followed into a function.

PyMOTW: heapq

A heap is a tree-like data structure where the child nodes have a sort-order relationship with the parents. Binary heaps can be represented using a list or array organized so that the children of element N are at positions 2N+1 and 2N+2 (for zero-based indexes). This feature makes it possible to rearrange heaps in place, so it is not necessary to reallocate as much memory when adding or removing items.

Python Magazine promotion for user groups

Over at Python Magazine we’re running a subscription promotion for members of user groups. If you help to organize a group that meets on a regular basis and discusses Python (possibly among other topics), drop me a line (doug dot hellmann at pythonmagazine dot com) and I’ll give you the details.

PyMOTW: cmd

The cmd module contains one public class, Cmd, designed to be used as a base class for command processors such as interactive shells and other command interpreters. By default it uses readline for interactive prompt handling, command line editing, and command completion. Read more at pymotw.com: cmd

virtualenvwrapper

Not content to leave well enough alone, Doug offers up some extensions to Ian Bicking’s virtualenv script that make it even more useful. Back in February, I introduced Ian Bicking’s virtualenv script for creating isolated Python environments, complete with their own interpreter and site-packages directory. I’ve been using virtualenv for all of my projects since then, but keeping up with all of the environments I have been creating has turned a little messy.

PyMOTW: functools

The functools module includes tools for wrapping functions and other callable objects. The primary tool supplied by the functools module is the class partial, which can be used to “wrap” a callable with default arguments. The resulting object is itself callable and can be treated as though it is the original function. It takes all of the same arguments as the original callable and can be invoked with extra positional or named arguments as well.

Python Magazine for April 2008

The April issue of Python Magazine is ready for download now. This month’s cover story from Zach Voase introduces bioinformatics with Python using BioPython. It’s amazing how easy it is to work with gene sequences in Python. Jeff Scudder provides an excellent article about using the Google Spreadsheet API like a database. We use Google Spreadsheet to manage some parts of the magazine, so I’m definitely looking forward to applying some of these techniques myself.

PyMOTW: filecmp

Compare files and directories easily with the filecmp module. Read more at pymotw.com: filecmp