homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zbysz
Recipients docs@python, patrick.vrijlandt, pitrou, rosslagerwall, zbysz
Date 2012年01月16日.16:34:12
SpamBayes Score 5.556731e-08
Marked as misclassified No
Message-id <1326731653.56.0.736520747715.issue13779@psf.upfronthosting.co.za>
In-reply-to
Content
> The documentation of this function is generally ambiguous, because
> os.walk is a generator. Thus "generate" means (1) yielded from a 
> generator and (2) prepared for later use within the generator. To avoid 
> the ambiguity, "generate" should be avoided if possible. (1) might be 
> replaced by "return" and (2) by "prepare".
It think that you are wrong here: generate is consistently used in
meaning (1) in the docstring. Also "return" means something completely different. "generate" is better than "prepare", because it is more specific,
especially from the POV of the user of the function, who only cares about
when something is yielded, not when it is prepared.
> Proposal (very verbose I'm afraid):
> If you change the directory structure below dirpath while topdown=True, 
> you can modify dirnames in-place so that walk will visit the right 
> directories. If you change the directory structure below dirpath while 
> topdown=False (maybe while you where there), dirnames and filenames can 
> still reflect the old situation and it might be necessary to call 
> os.listdir again.
Hm, I think that the difference in behaviour between topdown=False and topdown=True is smaller then this proposal implies.
When topdown=True, the list is not updated after changes on disk. So both removing and adding directories does _not_ cause them to added or removed from the list of subdirectories to visit. Nevertheless, the default behaviour on
error is to do nothing, so it _looks_ like they were skipped.
So I think that the documentation could only clarify that the list of subdirectories is queried first, before the dir or the subdirectories are "generated".
History
Date User Action Args
2012年01月16日 16:34:13zbyszsetrecipients: + zbysz, pitrou, docs@python, rosslagerwall, patrick.vrijlandt
2012年01月16日 16:34:13zbyszsetmessageid: <1326731653.56.0.736520747715.issue13779@psf.upfronthosting.co.za>
2012年01月16日 16:34:12zbyszlinkissue13779 messages
2012年01月16日 16:34:12zbyszcreate

AltStyle によって変換されたページ (->オリジナル) /