Browse Source
bpo-36769: Document that fnmatch.filter supports any kind of iterable (#13039)
pull/23848/head
Andre Delfino
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
2 deletions
-
Doc/library/fnmatch.rst
-
Lib/fnmatch.py
|
|
|
@ -75,7 +75,7 @@ patterns. |
|
|
|
|
|
|
|
.. function:: filter(names, pattern) |
|
|
|
|
|
|
|
Return the subset of the list of *names* that match *pattern*. It is the same as |
|
|
|
Construct a list from those elements of the iterable *names* that match *pattern*. It is the same as |
|
|
|
``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +52,7 @@ def _compile_pattern(pat): |
|
|
|
return re.compile(res).match |
|
|
|
|
|
|
|
def filter(names, pat): |
|
|
|
"""Return the subset of the list NAMES that match PAT.""" |
|
|
|
"""Construct a list from those elements of the iterable NAMES that match PAT.""" |
|
|
|
result = [] |
|
|
|
pat = os.path.normcase(pat) |
|
|
|
match = _compile_pattern(pat) |
|
|
|
|