Skip to content
19 changes: 19 additions & 0 deletions Lib/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
The order of the returned list is undefined. Sort it if you need a
particular order.

If root_dir is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If pathname is relative, the
result will contain paths relative to root_dir.

If dir_fd is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If root_dir is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If pathname is relative, the
result will contain paths relative to root_dir.
If dir_fd is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.
If `root_dir` is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If `pathname` is relative, the
result will contain paths relative to root_dir.
If `dir_fd` is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wary of "It has the same effect as changing the current directory before calling it" phrasing as we don't want anyone to think that the process wide global cwd is changed by these API calls. I think it may be better to state what the default behavior is when not specified or None. ie "if not specified or None, the search will be conducted from the processes current working directory and returned paths will be relative to that" (Q: is that accurate?)


If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
directories.

Expand All @@ -46,6 +54,17 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
The order of the returned paths is undefined. Sort them if you need a
particular order.

If root_dir is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If pathname is relative, the
result will contain paths relative to root_dir.

If dir_fd is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.

If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
directories.
Comment thread
hugovk marked this conversation as resolved.
Outdated

If recursive is true, the pattern '**' will match any files and
zero or more directories and subdirectories.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added missing explanations for some parameters in :func:`glob.glob` and
:func:`glob.iglob`.
Loading