bpo-36769: Document that fnmatch.filter supports any kind of iterable (GH-13039)
(cherry picked from commit e8d2264210
)
Co-authored-by: Andre Delfino <adelfino@gmail.com>
This commit is contained in:
parent
d21d29ab5b
commit
c37e3d1733
|
@ -75,7 +75,7 @@ patterns.
|
||||||
|
|
||||||
.. function:: filter(names, pattern)
|
.. 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.
|
``[n for n in names if fnmatch(n, pattern)]``, but implemented more efficiently.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ def _compile_pattern(pat):
|
||||||
return re.compile(res).match
|
return re.compile(res).match
|
||||||
|
|
||||||
def filter(names, pat):
|
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 = []
|
result = []
|
||||||
pat = os.path.normcase(pat)
|
pat = os.path.normcase(pat)
|
||||||
match = _compile_pattern(pat)
|
match = _compile_pattern(pat)
|
||||||
|
|
Loading…
Reference in New Issue