[Python-ideas] startsin ?
xtian
xtian at babbageclunk.com
Sat Oct 1 08:54:16 CEST 2011
More information about the Python-ideas mailing list
Sat Oct 1 08:54:16 CEST 2011
- Previous message: [Python-ideas] startsin ?
- Next message: [Python-ideas] startsin ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Sep 30, 2011 at 6:57 PM, Mike Graham <mikegraham at gmail.com> wrote: > On Fri, Sep 30, 2011 at 11:46 AM, David Stanek <dstanek at dstanek.com> wrote: >> >> I tend to do something like this a lot; >> any(somestring.startswith(x) for x in starts) >> Probably enough that having a method would be nice. > > I wonder if it might be worthwhile to give any and all two-parameter API for > predicate functions, so that > > any(f, xs) > > is the same as > > any(f(x) for x in xs) > > This eliminates some really common boilerplate, but it adds complication and > has an ugly API. > If you don't like the comprehension you could always use any(map(f, xs)).
- Previous message: [Python-ideas] startsin ?
- Next message: [Python-ideas] startsin ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list