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

MRAB python at mrabarnett.plus.com
Sat Nov 3 15:02:19 EDT 2018


On 2018-11-03 17:45, David Mertz wrote:
> On Sat, Nov 3, 2018, 1:30 PM Stephen J. Turnbull 
> <turnbull.stephen.fw at u.tsukuba.ac.jp 
> <mailto:turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
> 
>     P.S.   I can't resist.  This is horrible, but:
> 
>     def multifilter(names, *patterns):
>          return list(set().union(*[fnmatch.filter(names, p) for p in
>     patterns]))
> 
> 
> Yes, that is a horrible spelling for:
> 
>      {fnmatch.filter(names, p) for p in patterns}
> 
> ;-)
> 
But it has the advantage that it works. :-)


More information about the Python-ideas mailing list