os.walk trouble

BartlebyScrivener rpdooling at gmail.com
Thu Jun 1 12:42:42 EDT 2006


Neat. And looks better, at least on my machine, if you had a tab or two
and an extra \n after the dirs.

rick

for filepath, dirs, files in os.walk(root):
        #you're looking at the "dirs" and "files" in filepath
        print "Currently in %s" % filepath
        print "\t[Directories in %s]" % filepath
        print '\t' + "\n\t".join(dirs) + '\n'
        print "\t[Files in %s]" % filepath
        print '\t' + "\n\t".join(files)
        print "=" * 50




More information about the Python-list mailing list