[Python-ideas] "any" and "all" support multiple arguments
Nick Coghlan
ncoghlan at gmail.com
Tue Aug 1 11:28:24 EDT 2017
On 1 August 2017 at 23:24, Paul Moore <p.f.moore at gmail.com> wrote:
> On 1 August 2017 at 14:01, Louie Lu <me at louie.lu> wrote:
>> I'm not sure if this is discuss before, but can "any" and "all"
>> support like min_max "arg1, arg2, *args" style?
>
> I don't see any particular reason why not, but is there a specific use
> case for this or is it just a matter of consistency? Unlike max and
> min, we already have operators in this case (and/or). I'd imagine that
> if I had a use for any(a, b, c) I'd write it as a or b or c, and for
> all(a, b, c) I'd write a and b and c.
Right, the main correspondence here is with "sum()": folks can't write
"sum(a, b, c)", but they can write "a + b + c".
The various container constructors are also consistent in only taking
an iterable, with multiple explicit items being expected to use the
syntactic forms (e.g. [a, b, c], {a, b, c}, (a, b, c))
The same rationale holds for any() and all(): supporting multiple
positional arguments would be redundant with the existing binary
operator syntax, with no clear reason to ever prefer one option over
the other.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list