[Python-Dev] Re: os.path.walk() lacks 'depth first' option
Michael Chermside
mcherm@mcherm.com
Thu, 24 Apr 2003 09:44:09 -0700
Tim:
Don't get a swelled head or anything ;-), but your generator-based version
of walk() is beautiful piece of work. I don't mean the code (although that's
clean and readable), but the design. Using a generator is clearly good,
having it return (path,names) tuples is a nice way to work, and having
it return (path,dirnames,filenames) tuples is inspired. (If you want
them lumped together, just add the lists!) Allowing the consumer to
modify control the flow by modifying dirnames is very nice. And the fact
that it's so simple to code (22 short lines) is a testament to the power
of generators.
I'm +2 on putting this in immediately and deprecating os.path.walk().
-- Michael Chermside