E-Scribe News : a programmer’s blog

About Me

PBX My name is Paul Bissex, and e-scribe.com is my consulting business. I build web applications using as much open source software as possible. From September to June I teach web design and other important non-photographic professional skills to photographers. In the '90s I wrote technology commentary and reviews for magazines, newspapers, and web publications, including Wired, Salon.com, FamilyPC, the late lamented Web Review, and the Chicago Tribune. Feel free to email me.

Book Project

I'm co-authoring a book, "Python Web Development with Django", with Jeff Forcier and Wesley Chun. It will be published by Prentice Hall in July 2008, but is available for pre-ordering on Amazon now.

Colophon

This site is built on a fresh trunk checkout of Django, running on Python 2.5.1, served by Apache and mod_python. The database is SQLite. The operating system is FreeBSD, on a VPS hosted at Johncompanies.com. Comment-spam protection by Akismet. Vintage topo imagery from the Maptech archive.

Pile o'Tags

Stuff I Use

Akismet, del.icio.us, Django, dpaste.com, Emacs, FreeBSD, Freenode, jQuery, LaunchBar, MacPorts, Markdown, Mercurial, OS X, Postfix, Python, SQLite, Subversion, TextMate, Trac, Ubuntu Linux, wmii

A Django site.
(Finally!)

Copyright 2008
by Paul Bissex
and E-Scribe New Media

The "path" module

Somewhat belatedly I've started using Jason Orendorff's path module for Python. It's great. Here's a comparison with the stock os.path facilities, grabbed from Jason's site:

# with os.path.walk
def delete_backups(arg, dirname, names):
    for name in names:
        if name.endswith('~'):
            os.remove(os.path.join(dirname, name))
os.path.walk(os.environ['HOME'], delete_backups, None)

# with path
d = path(os.environ['HOME'])
for f in d.walkfiles('*~'):
    f.remove()

The second snippet is not just shorter, it's easier to read and easier to write. I'm writing some code to recursively process a tree of short text files (Blosxom entries), and the path module is a godsend. If you're curious, see the description and examples on Jason's site; he also posted some interesting comments on Ian Bicking's blog about the design of the module.

I gather that there was significant interest in getting some version of this module included in Python 2.5, but I don't see any mention of it in the release notes. There's PEP 355 and a python-dev discussion from January. But unless I missed something (I'm still mostly using Python 2.4), it's not in 2.5 in any form. Here's hoping it makes it into 2.6...

Update: Bummer. Dead.

Thursday, September 28th, 2006
+
4 comments

Comment from Paul, later that day

Good find -- thanks, Lawrence!

Comment from Lawrence Oluyede, 1 day later

GvR just said the path module will not get into Python so... that's it.

Comment from Paul, 1 day later

Yeah, I saw that and added my "bummer" update link above. Oh well. I guess it will just be part of my own little library for now.

Post a comment

Comments use Markdown syntax. Your comment will not appear until approved, which may take a few hours or more. Spammers will be torpedoed.


(Will not be shared)

(Optional)