[issue29433] any, all and sum should accept variadic args

Steven D'Aprano report at bugs.python.org
Fri Feb 3 08:38:54 EST 2017


Steven D'Aprano added the comment:

Serhiy, that doesn't generalise to code like:

    any(a, b, c, *extras)

which is hard to write out by hand. You would have to say 

    bool(a or b or c or any(extras))

I think this might be worth considering on Python-Ideas. It will probably be rejected, but if Sedrubal cares enough to raise the idea, it could be discussed.

However, sum should be taken off the list. The problem with accepting variadic args is that it clashes with current behaviour:

    sum( [[1], [2], [3]], [4, 5] )

That would be ambiguous. Under the suggested variadic form, that should return a list:

    [[1], [2], [3], 4, 5]

but it already has a meaning in Python today:

    [4, 5, 1, 2, 3]


So sum() with variadic args would be ambiguous, or would break backwards compatibility. Neither of those would be acceptable.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29433>
_______________________________________


More information about the Python-bugs-list mailing list