Path Module

If you like to use Python frequently for shell scripts, this module will interest you. A module for very simple processing of directory names and filenames, which is much more elegant than os.path. Additionally, it combines the functions of the glob module and the shutil module.

What normally looks like this with os.path:

 # with os.path DIR = '/usr/home/guido/bin' for f in os.listdir(DIR):
if f.endswith('.py'): path = os.path.join(DIR, f) os.chmod(path, 0755) # Assume it's a file

Looks like this with the path module:

 # with path dir = path('/usr/home/guido/bin') for f in dir.files('*.py'): f.chmod(0755)

Here you can find the original article.