[Python-ideas] "any" and "all" support multiple arguments

Ned Batchelder ned at nedbatchelder.com
Tue Aug 1 09:43:04 EDT 2017


I find it frustrating that they always return booleans.  It would be
more useful if any() returned the first true value it finds.  This seems
like a backward-compatible-enough change to me... :)

--Ned.


On 8/1/17 9:32 AM, Markus Meskanen wrote:
> I'd be more interested in supporting the "key" function:
>
> any(users, key=User.is_admin)
>
> As opposed to:
>
> any(user.is_admin() for user in users)
>
> 1.8.2017 16.07 "Louie Lu" <me at louie.lu <mailto:me at louie.lu>> kirjoitti:
>
>     Hi all,
>
>     In "min" and "max" builtin-func, it support two style of args:
>
>         min(...)
>             min(iterable, *[, default=obj, key=func]) -> value
>             min(arg1, arg2, *args, *[, key=func]) -> value
>
>     But for "any" and "all", it only support iterable:
>
>         all(iterable, /)
>             Return True if bool(x) is True for all values x in the
>     iterable.
>
>
>     I'm not sure if this is discuss before, but can "any" and "all"
>     support like min_max "arg1, arg2, *args" style?
>
>
>     Thanks,
>     Louie.
>     _______________________________________________
>     Python-ideas mailing list
>     Python-ideas at python.org <mailto:Python-ideas at python.org>
>     https://mail.python.org/mailman/listinfo/python-ideas
>     <https://mail.python.org/mailman/listinfo/python-ideas>
>     Code of Conduct: http://python.org/psf/codeofconduct/
>     <http://python.org/psf/codeofconduct/>
>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

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


More information about the Python-ideas mailing list