postprocessing in os.walk

Ethan Furman ethan at stoneleaf.us
Tue Oct 13 12:57:56 EDT 2009


kj wrote:
> In <mailman.1196.1255347115.2807.python-list at python.org> Dave Angel <davea at ieee.org> writes:
>>

[snippetty snip]

>>Why would you need a special hook when the os.walk() generator yields 
>>exactly once per directory?  So whatever work you do on the list of 
>>files you get, you can then put the summary logic immediately after.
> 
> 
> I think you're missing the point.  The hook in question has to be
> called *immediately after* all the subtrees that are rooted in
> subdirectories contained in the current directory have been visited
> by os.walk.
> 
> I'd love to see your "5 lines" for *that*.
> 
> kj

So now that you've seen a couple examples, perhaps you noticed the flag 
"topdown=False"?  With that (un)set, I repeat the question -- why do you 
need a hook?

~Ethan~



More information about the Python-list mailing list