[Python-ideas] Make fnmatch.filter accept a tuple of patterns

David Mertz mertz at gnosis.cx
Sat Nov 3 15:29:26 EDT 2018


On Sat, Nov 3, 2018 at 3:03 PM MRAB <python at mrabarnett.plus.com> wrote:

> > Yes, that is a horrible spelling for:
> >
> >      {fnmatch.filter(names, p) for p in patterns}
>


> But it has the advantage that it works. :-)
>

Indeed! Excellent point :-).  I definitely should not post untested code
from my tablet.

This is still slightly less horrible, but I recognize it's starting to
border on horrible:

    {n for p in patterns for n in fnmatch.filter(names, p)}

This seems worse:

    set(chain(*(fnmatch.filter(names, p) for p in patterns)))

-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181103/bacd03f2/attachment.html>


More information about the Python-ideas mailing list