[Adam DePrince] > Each iteration of os.walk returns three parameters; one of those, > dirs, is a list of directories within the current directory pointed at > by root.
Right. > Am I correct to assume that you beleve that by changing the > contents of dir you will affect how os.walk traverses the > directories. If so, that is your problem. Nope, mutating dirs is the intended way to prune (or even to augment) os.walk's search tree on the fly See the docs. Gabriel's problem was mutating dirs while iterating over it in another level of loop; while os.walk() expects that its caller may mutate dirs, and "does the right thing" if the caller does, Gabriel's own loop wasn't safe against mutation during iteration. -- http://mail.python.org/mailman/listinfo/python-list