
Oct. 1, 2011
6:54 a.m.
On Fri, Sep 30, 2011 at 6:57 PM, Mike Graham <mikegraham@gmail.com> wrote:
On Fri, Sep 30, 2011 at 11:46 AM, David Stanek <dstanek@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)).