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

Bruce Leban bruce at leapyear.org
Sun Nov 21 22:21:15 CET 2010

It is an improvement if there's no function. I think

    any(i > 3 for i in foo)

is more readable than

    any(map(lambda i: i > 3, foo))

As to the original suggestion, the length of any(foo, test=bar) vs
any(map(bar, foo)) is about the same. So I think this doesn't make anything
simpler and unnecessarily adds complexity to any/all which then will
inevitably lead to suggestions to make other things more complicated to
match them.

--- Bruce
Learn about security: http://j.mp/gruyere-security

On Sun, Nov 21, 2010 at 12:20 PM, Masklinn <masklinn at masklinn.net> wrote:

> On 2010-11-21, at 21:11 , MRAB wrote:
> >
> > if any(mytestfunction(i) for i in mylist):
> >    foo()
> is not an improvement over `if any(map(mytestfunction, mylist))` or `if
> any(imap(mytestfunction, mylist))`
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101121/1d3c52a3/attachment.html>

More information about the Python-ideas mailing list