diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-06-16 03:51:12 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-06-16 03:51:12 (GMT) |
commit | 87d01364167e55e62c1e9ebe0892c3d5266d0428 (patch) | |
tree | 4cbed1e3d04dc524e7baafe4f38e5b18255444ba | |
parent | efda558b60739bee311b53f521ac69f63b726de7 (diff) | |
download | cpython-87d01364167e55e62c1e9ebe0892c3d5266d0428.zip cpython-87d01364167e55e62c1e9ebe0892c3d5266d0428.tar.gz cpython-87d01364167e55e62c1e9ebe0892c3d5266d0428.tar.bz2 |
clarify when the list of subdirectories is read (closes #13779)
-rw-r--r-- | Doc/library/os.rst | 8 | ||||
-rw-r--r-- | Lib/os.py | 12 |
2 files changed, 12 insertions, 8 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 71133c4..f67ca25 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1604,9 +1604,11 @@ Files and Directories If optional argument *topdown* is ``True`` or not specified, the triple for a directory is generated before the triples for any of its subdirectories - (directories are generated top-down). If *topdown* is ``False``, the triple for a - directory is generated after the triples for all of its subdirectories - (directories are generated bottom-up). + (directories are generated top-down). If *topdown* is ``False``, the triple + for a directory is generated after the triples for all of its subdirectories + (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 (perhaps using :keyword:`del` or slice assignment), and :func:`walk` will only @@ -229,11 +229,12 @@ def walk(top, topdown=True, onerror=None, followlinks=False): 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 - subdirectories whose names remain in dirnames; this can be used to prune - the search, or to impose a specific order of visiting. Modifying - dirnames when topdown is false is ineffective, since the directories in - dirnames have already been generated by the time dirnames itself is - generated. + subdirectories whose names remain in dirnames; this can be used to prune the + search, or to impose a specific order of visiting. Modifying dirnames when + topdown is false is ineffective, since the directories in dirnames have + already been generated by the time dirnames itself is generated. No matter + 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 optional arg 'onerror' is specified, it should be a function; it @@ -261,6 +262,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False): print "bytes in", len(files), "non-directory files" if 'CVS' in dirs: dirs.remove('CVS') # don't visit CVS directories + """ islink, join, isdir = path.islink, path.join, path.isdir |