"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def build_clean_list(self, path): > > file_skip_list = ['search_results.txt'] > dir_skip_list = ['dev', 'proc', 'Temporary Internet Files'] > > fs_objects = os.walk(path, topdown=True) > ## for fs in fs_objects: > ## > ## for f in fs[2]: > ## if f in file_skip_list: > ## print f > ## fs[2].remove(f) > ## > ## for d in fs[1]: > ## if d in dir_skip_list: > ## print d > ## fs[1].remove(d) > > return fs_objects
Rather as an aside, the idiom for using os.walk is for dirpath, dirnames, dirfiles in os.walk(path): for f in dirnames: if f in file_skip_list: print f filenames.remove(f) if d in dir_skip_list: print d dirnames.remove(f) More crucially for your code, returning the generator object after having iterated all the way through it will not do you any good. The generator has an internal state that puts it at "the end of the iteration" so you cannot use it to iterate again. -- http://mail.python.org/mailman/listinfo/python-list