The calendar module defines the Calendar class, which encapsulates calculations for values such as the dates of the weeks in a given month or year. In addition, the TextCalendar and HTMLCalendar classes can produce pre-formatted output.
Read more at pymotw.com: calendar
I have spent the better part of the morning trying to work out how to convert podcasts to “regular” tracks in iTunes, so they would show up in shuffle, etc. Mostly this was for my collection of Jonathan Coulton “Thing a Week” episodes, but it would be useful for anything you wanted to move out of your podcast list into the main audio portion of the library. I suppose the reason it took so long to find the solution is I started by searching for it on Google instead of just looking through the iTunes menu options, though as you will see the solution wasn’t immediately obvious even once I had found it.
Yesterday Pierre Lemay sent me one of the clearest bug reports I’ve seen in quite a while, and a patch to fix the problem. He was having trouble with svnbackup duplicating changesets in the dump files. It turns out every changeset that appeared on a “boundary” (at the end of one dump file and the beginning of the next) was included in both dumps. Oops.
When I tested the script, I was able to recover the repository without any trouble.
Many programs which interact with the user via the terminal need to ask the user for password values without showing what the user types on the screen. The getpass module provides a portable way to handle such password prompts securely.
Read more at pymotw.com: getpass
My svnbackup script is the second most popular page on my site, after the PyMOTW home page, and search terms such as “svn backup” and “svn backup script” regularly appear at the top of the list of sources of traffic to my site. The link to svnbackup doesn’t appear on the first page of Google’s search results, a sign I take to mean that this problem isn’t well understood or solved (otherwise, why would so many people page through the search results to find it?
The atexit module provides a simple interface to register functions to be called when a program closes down normally. The sys module also provides a hook, sys.exitfunc, but only one function can be registered there. The atexit registry can be used by multiple modules and libraries simultaneously.
Read more at pymotw.com: atexit
The subprocess module provides a consistent interface to creating and working with additional processes. It offers a higher-level interface than some of the other available modules, and is intended to replace functions such as os.system, os.spawn*, os.popen*, popen2.* and commands.*. To make it easier to compare subprocess with those other modules, this week I will re-create earlier examples using the functions being replaced.
Read more at pymotw.com: subprocess
The pickle module implements an algorithm for turning an arbitrary Python object into a series of bytes (“serializing” the object). The byte stream can then be transmitted or stored, and later reconstructed to create a new object with the same characteristics.
The cPickle module implements the same algorithm, in C instead of Python. It is many times faster than the Python implementation, but does not allow the user to subclass from Pickle.
I spent a little time last night trying to assemble an application using DjangoKit without much success.
I’m running Python 2.5 on a PowerBook with Mac OS 10.4. I downloaded and installed PyObjC from source so it would compile (I thought) against the right version of Python, then installed DjangoKit using python setup.py install. Everything seemed to be working, and I was able to build an application. But when I ran that app, it produced an error about the version of the SQLite libraries being used (2 instead of 3) and missing libraries.
This week I am wrapping up coverage of the os module (saving os.path for a future post of its own) and discuss functions useful for working with multiple processes. I covered use of pipes in part 2, so this week we will look at system(), fork(), exec(), and related functions.
Read more at pymotw.com: os/index.html#running-external-commands