DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Using Path Module

  • submit to reddit
        Here's an example codes using <a href=>path module</a>.
You first need to download it here: <a href=></a>
# make some files excutable
d = path('/usr/home/guido/bin')
for f in d.files('*.py'):

# Directory walking - delete Emacs backup files
d = path(os.environ['HOME'])
for f in d.walkfiles('*~'):
Using os.path is difficult. I can hardly remember how to
use which method. Need to lookup the manual every time.
This path module is much much easier to use.
I've heard it will be included in python 2.5 as well.