Skip to content

bpo-36769: Document that fnmatch.filter supports any kind of iterable #13039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/fnmatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
2 changes: 1 addition & 1 deletion Lib/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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)
Expand Down