Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > # Untested > last_visited = open("last_visited.txt", 'r').read() > for root, dirs, files in os.walk(last_visited or basedir): > open("last_visited.txt", 'w').write(root) > run program
Wouldn't this only walk the directory the exception occured in and not the remaining unwalked dirs from basedir? Something like this should work: import os basedir = '.' walked = open('walked.txt','r').read().split() unwalked = ((r,d,f) for r,d,f in os.walk(basedir) if r not in walked) for root, dirs, files in unwalked: # do something print root walked.append(root) open('walked.txt','w').write('\n'.join(walked)) -- http://mail.python.org/mailman/listinfo/python-list