Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ def _add(str, fn):
def makedirs(name, mode=0o777, exist_ok=False, *, parent_mode=None):
"""makedirs(name [, mode=0o777][, exist_ok=False][, parent_mode=None])

Super-mkdir; create a leaf directory and all intermediate ones. Works like
mkdir, except that any intermediate path segment (not just the rightmost)
will be created if it does not exist. If the target directory already
exists, raise an OSError if exist_ok is False. Otherwise no exception is
raised. If parent_mode is not None, it will be used as the mode for any
newly-created, intermediate-level directories. Otherwise, intermediate
directories are created with the default permissions (respecting umask).
This is recursive.
Super-mkdir; create a leaf directory and all intermediate ones. Works
like mkdir, except that any intermediate path segment (not just the
rightmost) will be created if it does not exist. If the target
directory already exists, raise an OSError if exist_ok is False.
Otherwise no exception is raised. If parent_mode is not None, it will
be used as the mode for any newly-created, intermediate-level
directories. Otherwise, intermediate directories are created with the
default permissions (respecting umask). This is recursive.

"""
head, tail = path.split(name)
Expand Down Expand Up @@ -321,12 +321,12 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
dirpath, dirnames, filenames

dirpath is a string, the path to the directory. dirnames is a list of
the names of the subdirectories in dirpath (including symlinks to directories,
and excluding '.' and '..').
the names of the subdirectories in dirpath (including symlinks to
directories, and excluding '.' and '..').
filenames is a list of the names of the non-directory files in dirpath.
Note that the names in the lists are just names, with no path components.
To get a full path (which begins with top) to a file or directory in
dirpath, do os.path.join(dirpath, name).
Note that the names in the lists are just names, with no path
components. To get a full path (which begins with top) to a file or
directory in dirpath, do os.path.join(dirpath, name).

If optional arg 'topdown' is true or not specified, the triple for a
directory is generated before the triples for any of its subdirectories
Expand All @@ -336,13 +336,13 @@ 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 has no effect on the behavior of os.walk(), 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.
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 has no effect on the behavior of
os.walk(), 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.scandir() call are ignored. If
optional arg 'onerror' is specified, it should be a function; it
Expand Down Expand Up @@ -469,9 +469,9 @@ def fwalk(top=".", topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=
The advantage of fwalk() over walk() is that it's safe against symlink
races (when follow_symlinks is False).

If dir_fd is not None, it should be a file descriptor open to a directory,
and top should be relative; top will then be relative to that directory.
(dir_fd is always supported for fwalk.)
If dir_fd is not None, it should be a file descriptor open to
a directory, and top should be relative; top will then be relative to
that directory. (dir_fd is always supported for fwalk.)

Caution:
Since fwalk() yields file descriptors, those are only valid until the
Expand Down
Loading
Loading