In <mailman.86.1273631889.32709.python-l...@python.org> Tim Chase writes: > 05/11/2010 09:07 PM, Terry Reedy wrote: >> If os.walk were rewritten, it should be as an iterator (generator). >> Directory entry and exit functions could still be added as params.
>It *is* an iterator/generator. However, I suspect you mean that >it should slurp the dirs/files iteratively instead of using >listdir() as was discussed on c.l.p a few months back. Thanks for mentioning this thread. Very interesting stuff. Apropos the implementability of an iterative listdir, I wonder if some variation of glob.iglob() would fit the bill. (Maybe it's too slow, though.) >I suspect if I thought about it much longer, only one would >really be needed, the other accommodated by the "topdown" parameter. Yeah, I think one only needs a post hook. The fact that it's a generator obviates need for a pre hook, since the yield returns control to the calling function right around where the pre-hook would run anyway. For the same reason, the post hook is needed only for the case topdown=True. Another useful callback would be one that replaced listdir in the generation of the current directory's contents. ~K -- http://mail.python.org/mailman/listinfo/python-list