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

2017-02-03 Thread Steven D'Aprano

Steven D'Aprano added the comment:

> Do you think I should send a mail to the ideas list?

Personally, I don't think so. You want to write any(a, b, c, d), 
but you can get the same effect now by writing any([a, b, c, d]).
There is unlikely to be any significant performance difference.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-02-03 Thread sedrubal

sedrubal added the comment:

Thanks for your answers and for showing the issue with sum.

I think this would make python just a bit more sexier as it already is ;) Are 
there any other disadvantages (performance, ...)?

Do you think I should send a mail to the ideas list?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-02-03 Thread Steven D'Aprano

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-02-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is no such need. You can use operators.

any(arg1, arg2, arg3) -> arg1 or arg2 or arg3
all(arg1, arg2, arg3) -> arg1 and arg2 and arg3
sum(arg1, arg2, arg3) -> arg1 + arg2 + arg3

--
nosy: +serhiy.storchaka
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2017-02-03 Thread sedrubal

New submission from sedrubal:

any, all and sum (and maybe some other functions) should accept variadic args. 
It should be possible to do things like this:

>>> any(True, False, True)
True
>>> all(True, False, True)
False
>>> sum(1, 2, 3)
6

This was compliant to max and min behaviour:

>>> max(1, 2, 3)
3
>>> min(1, 2, 3)
1

--
messages: 286859
nosy: sedrubal
priority: normal
severity: normal
status: open
title: any, all and sum should accept variadic args
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com