Well, you could use the alternative os.path.walk instead. You can pass a callback as a parameter, which will be invoked every time you bump into a new directory. The signature is os.path.walk (path,visit,arg). Take a look at the python library documentation.
On 11 Oct, 00:12, kj <no.em...@please.post> wrote: > Perl's directory tree traversal facility is provided by the function > find of the File::Find module. This function accepts an optional > callback, called postprocess, that gets invoked "just before leaving > the currently processed directory." The documentation goes on to > say "This hook is handy for summarizing a directory, such as > calculating its disk usage", which is exactly what I use it for in > a maintenance script. > > This maintenance script is getting long in the tooth, and I've been > meaning to add a few enhancements to it for a while, so I thought > that in the process I'd port it to Python, using the os.walk > function, but I see that os.walk does not have anything like this > File::Find::find's postprocess hook. Is there a good way to simulate > it (without having to roll my own File::Find::find in Python)? > > TIA! > > kynn -- http://mail.python.org/mailman/listinfo/python-list