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

Ben Finney ben+python at benfinney.id.au
Sun Nov 21 23:31:14 CET 2010

Masklinn <masklinn at masklinn.net> writes:

> 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))`

It is definitely an improvement by the criterion the OP mentioned, which

Andy Buckley <andy at insectnation.org> writes:

> I either have to explicitly re-code a slightly modified version of the
> builtin, or wastefully use map() to apply my test to *all* the items
> in the list.

 \           “If [a technology company] has confidence in their future |
  `\      ability to innovate, the importance they place on protecting |
_o__)     their past innovations really should decline.” —Gary Barnett |
Ben Finney

More information about the Python-ideas mailing list