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

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

On Sun, Nov 21, 2010 at 6:40 PM, Carl M. Johnson <
cmjohnson.mailinglist at gmail.com> wrote:

> On Sun, Nov 21, 2010 at 1:12 PM, Steven D'Aprano wrote:
> Having said that, I'd suggest that an appropriate name might be the same
>> name used by sort and friends: key.
> I agree with almost everything you wrote, except the suggestion of "key".
> [...]
> None of this applies to any/all, since they just return a True or a False,
> no matter what kind of iterable input they get.

However, if any/all acted like or/and and returned the last value examined
(rather than simply True/False), then "key" would make sense.  Then they
turn into more useful selection tools.

There have been several times when I wished that any/all acted like or/and
because I needed the offending value for further use...

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

More information about the Python-ideas mailing list