mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
clarify when the list of subdirectories is read (closes #13779)
This commit is contained in:
parent
9204e09178
commit
e58e0c7f33
2 changed files with 12 additions and 8 deletions
|
@ -2228,9 +2228,11 @@ features:
|
||||||
|
|
||||||
If optional argument *topdown* is ``True`` or not specified, the triple for a
|
If optional argument *topdown* is ``True`` or not specified, the triple for a
|
||||||
directory is generated before the triples for any of its subdirectories
|
directory is generated before the triples for any of its subdirectories
|
||||||
(directories are generated top-down). If *topdown* is ``False``, the triple for a
|
(directories are generated top-down). If *topdown* is ``False``, the triple
|
||||||
directory is generated after the triples for all of its subdirectories
|
for a directory is generated after the triples for all of its subdirectories
|
||||||
(directories are generated bottom-up).
|
(directories are generated bottom-up). No matter the value of *topdown*, the
|
||||||
|
list of subdirectories is retrieved before the tuples for the directory and
|
||||||
|
its subdirectories are generated.
|
||||||
|
|
||||||
When *topdown* is ``True``, the caller can modify the *dirnames* list in-place
|
When *topdown* is ``True``, the caller can modify the *dirnames* list in-place
|
||||||
(perhaps using :keyword:`del` or slice assignment), and :func:`walk` will only
|
(perhaps using :keyword:`del` or slice assignment), and :func:`walk` will only
|
||||||
|
|
12
Lib/os.py
12
Lib/os.py
|
@ -312,11 +312,12 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
|
||||||
|
|
||||||
When topdown is true, the caller can modify the dirnames list in-place
|
When topdown is true, the caller can modify the dirnames list in-place
|
||||||
(e.g., via del or slice assignment), and walk will only recurse into the
|
(e.g., via del or slice assignment), and walk will only recurse into the
|
||||||
subdirectories whose names remain in dirnames; this can be used to prune
|
subdirectories whose names remain in dirnames; this can be used to prune the
|
||||||
the search, or to impose a specific order of visiting. Modifying
|
search, or to impose a specific order of visiting. Modifying dirnames when
|
||||||
dirnames when topdown is false is ineffective, since the directories in
|
topdown is false is ineffective, since the directories in dirnames have
|
||||||
dirnames have already been generated by the time dirnames itself is
|
already been generated by the time dirnames itself is generated. No matter
|
||||||
generated.
|
the value of topdown, the list of subdirectories is retrieved before the
|
||||||
|
tuples for the directory and its subdirectories are generated.
|
||||||
|
|
||||||
By default errors from the os.listdir() call are ignored. If
|
By default errors from the os.listdir() call are ignored. If
|
||||||
optional arg 'onerror' is specified, it should be a function; it
|
optional arg 'onerror' is specified, it should be a function; it
|
||||||
|
@ -344,6 +345,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
|
||||||
print("bytes in", len(files), "non-directory files")
|
print("bytes in", len(files), "non-directory files")
|
||||||
if 'CVS' in dirs:
|
if 'CVS' in dirs:
|
||||||
dirs.remove('CVS') # don't visit CVS directories
|
dirs.remove('CVS') # don't visit CVS directories
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
islink, join, isdir = path.islink, path.join, path.isdir
|
islink, join, isdir = path.islink, path.join, path.isdir
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue