os.walk() dirs and files

rtilley rtilley at vt.edu
Wed Feb 8 08:27:15 EST 2006


Hello,

When working with file and dir info recursively on Windows XP. I'm going 
about it like this:

for root, dirs, files in os.walk(path):
     for f in files:
         ADD F to dictionary
     for d in dirs:
         ADD D to dictionary

Is it possible to do something such as this:

for root, dirs, files in os.walk(path):
     for f,d in files, dirs:
         ADD F|D to dictionary

Just trying to save some lines of code and thought it wise to ask the 
gurus before trying it :)

Thanks!



More information about the Python-list mailing list