[Python-ideas] startsin ?

Mike Graham mikegraham at gmail.com
Fri Sep 30 19:57:14 CEST 2011

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110930/ecb599fa/attachment.html>

More information about the Python-ideas mailing list