os.walk trouble

Kent Johnson kent at kentsjohnson.com
Thu Jun 1 20:36:45 CEST 2006

The Prophet wrote:
> As my first Python script, I am trying to make a program that recurses
> a directory searching for files whose names match a pattern. 

If your patterns are simple (supported by fnmatch), the path module 
makes this very easy:
import path
for f in path.path(dirname).walkfiles('*.foo'):
   # process a .foo file here



More information about the Python-list mailing list