Skip to content

Commit 50bb9c6

Browse files
miss-islingtonerlend-aaslandAA-Turner
authored
[3.12] gh-94220: Align fnmatch docs with the implementation and amend markup (GH-114152) (#114155)
- Align the argument spec for fnmatch functions with the actual implementation. - Update Sphinx markup to recent recommandations. - Add link to 'iterable' glossary entry. (cherry picked from commit 6e84f3b) Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent 0ee681a commit 50bb9c6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Doc/library/fnmatch.rst

+14-12
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is used t
5050
cache the compiled regex patterns in the following functions: :func:`fnmatch`,
5151
:func:`fnmatchcase`, :func:`.filter`.
5252

53-
.. function:: fnmatch(filename, pattern)
53+
.. function:: fnmatch(name, pat)
5454

55-
Test whether the *filename* string matches the *pattern* string, returning
56-
:const:`True` or :const:`False`. Both parameters are case-normalized
55+
Test whether the filename string *name* matches the pattern string *pat*,
56+
returning ``True`` or ``False``. Both parameters are case-normalized
5757
using :func:`os.path.normcase`. :func:`fnmatchcase` can be used to perform a
5858
case-sensitive comparison, regardless of whether that's standard for the
5959
operating system.
@@ -69,22 +69,24 @@ cache the compiled regex patterns in the following functions: :func:`fnmatch`,
6969
print(file)
7070

7171

72-
.. function:: fnmatchcase(filename, pattern)
72+
.. function:: fnmatchcase(name, pat)
7373

74-
Test whether *filename* matches *pattern*, returning :const:`True` or
75-
:const:`False`; the comparison is case-sensitive and does not apply
76-
:func:`os.path.normcase`.
74+
Test whether the filename string *name* matches the pattern string *pat*,
75+
returning ``True`` or ``False``;
76+
the comparison is case-sensitive and does not apply :func:`os.path.normcase`.
7777

7878

79-
.. function:: filter(names, pattern)
79+
.. function:: filter(names, pat)
8080

81-
Construct a list from those elements of the iterable *names* that match *pattern*. It is the same as
82-
``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
81+
Construct a list from those elements of the :term:`iterable` *names*
82+
that match pattern *pat*.
83+
It is the same as ``[n for n in names if fnmatch(n, pat)]``,
84+
but implemented more efficiently.
8385

8486

85-
.. function:: translate(pattern)
87+
.. function:: translate(pat)
8688

87-
Return the shell-style *pattern* converted to a regular expression for
89+
Return the shell-style pattern *pat* converted to a regular expression for
8890
using with :func:`re.match`.
8991

9092
Example:

0 commit comments

Comments
 (0)