[Python-ideas] Adding an optional function argument to all() and any() builtins

Bruce Frederiksen dangyogi at gmail.com
Mon Nov 22 16:58:57 CET 2010

On Mon, Nov 22, 2010 at 6:32 AM, Tim Lesher <tlesher at gmail.com> wrote:

> That could be the source of some frightening, hard-to-detect regressions:
> if any([-1,0,1], test=is_even):
>    # never taken, because 0 is returned instead of True

Good point!  The only way out of this for what I was wanting that I can
think of becomes:

first_even = next(filter(is_even, [-1, 0, 1]), None)

In which case, I already have all of the tools that I need!

I withdraw my suggestion.

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

More information about the Python-ideas mailing list