On 5/12/2010 2:52 PM, kj wrote:
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.

Yes, I was thinking of that thread.

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.

Once you have determined and tested the minimal needed change for greater functionality, you could either
a) post a suggestion and the revised os.walk to python-ideas
b) submit a feature request to the tracker and attach the revised function and, if possible, a diff patch
c) both.

I have no idea of the response.

Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to