dirwalk.py generator version of os.path.walk
Tom Good
Tom_Good1 at excite.com
Fri Mar 1 14:58:03 EST 2002
jimd at vega.starshine.org (Jim Dennis) wrote in message news:<a5mbm7$18vj$1 at news.idiom.com>...
> In article <just-BED145.11365928022002 at news1.xs4all.nl>, Just van Rossum wrote:
> >In article <a5kv49$ae8$2 at news.idiom.com>,
> > jimd at vega.starshine.org (Jim Dennis) wrote:
>
> >>> I wrote a different implementation of this general concept at:
>
> >>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/105873
>
> >>> You don't really need to keep a stack of directories and push/pop
> >>> things, because with generators you can recurse instead.
> >>> Tom
>
> BTW: Tom, I did come across your version in the ASPN a day or so
> after I wrote mine. I agree it looks cleaner and simpler.
> I might still use a list (FIFO or stack) and while loop instead
> of the recursion. (see below).
>
If you've considered both approaches and prefer a non-recursive
implementation, then sure, do it the way you like best. I wanted to
point out another option in case you hadn't thought of it.
[snip]
> However, it would be nice if I
> created a useful Python module which provided all of the power
> for Python that the "find" command provides to the shell.
That sounds cool. Post it when you're done :-)
Tom
More information about the Python-list
mailing list