Skip to content

Commit e542255

Browse files
gh-144835: Added missing explanations for some parameters in glob and iglob. (#144836)
* Added missing explanations for some parameters in glob and iglob. * News entry. * Added proper 'func' indication in News file. * Consistent use of backticks. * Improved wording. * consistent wording between the two docstrings --------- Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
1 parent 8bcb3ea commit e542255

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

Lib/glob.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
1717
include_hidden=False):
18-
"""Return a list of paths matching a pathname pattern.
18+
"""Return a list of paths matching a `pathname` pattern.
1919
2020
The pattern may contain simple shell-style wildcards a la
2121
fnmatch. Unlike fnmatch, filenames starting with a
@@ -25,6 +25,15 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
2525
The order of the returned list is undefined. Sort it if you need a
2626
particular order.
2727
28+
If `root_dir` is not None, it should be a path-like object specifying the
29+
root directory for searching. It has the same effect as changing the
30+
current directory before calling it (without actually
31+
changing it). If pathname is relative, the result will contain
32+
paths relative to `root_dir`.
33+
34+
If `dir_fd` is not None, it should be a file descriptor referring to a
35+
directory, and paths will then be relative to that directory.
36+
2837
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
2938
directories.
3039
@@ -36,7 +45,7 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
3645

3746
def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
3847
include_hidden=False):
39-
"""Return an iterator which yields the paths matching a pathname pattern.
48+
"""Return an iterator which yields the paths matching a `pathname` pattern.
4049
4150
The pattern may contain simple shell-style wildcards a la
4251
fnmatch. However, unlike fnmatch, filenames starting with a
@@ -46,7 +55,19 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
4655
The order of the returned paths is undefined. Sort them if you need a
4756
particular order.
4857
49-
If recursive is true, the pattern '**' will match any files and
58+
If `root_dir` is not None, it should be a path-like object specifying
59+
the root directory for searching. It has the same effect as changing
60+
the current directory before calling it (without actually
61+
changing it). If pathname is relative, the result will contain
62+
paths relative to `root_dir`.
63+
64+
If `dir_fd` is not None, it should be a file descriptor referring to a
65+
directory, and paths will then be relative to that directory.
66+
67+
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
68+
directories.
69+
70+
If `recursive` is true, the pattern '**' will match any files and
5071
zero or more directories and subdirectories.
5172
"""
5273
sys.audit("glob.glob", pathname, recursive)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added missing explanations for some parameters in :func:`glob.glob` and
2+
:func:`glob.iglob`.

0 commit comments

Comments
 (0)