On Wed, Aug 13, 2014 at 2:03 PM, Antoine Pitrou <antoine@python.org> wrote:
Le 13/08/2014 12:37, Steven D'Aprano a écrit :
sum() is *not* the One Obvious Way to add arbitrary objects in every domain.
Well, it is. It's a builtin and it's called "sum", which makes it pretty clear it adds objects together. That could hardly be any more obvious, actually: all competitors are *less* obvious.
When it comes to "adding" sequences or containers, "concat" would be a strong competitor. After all, this is exactly what + does on sequences under the hood. [1] While there are technical reasons for reusing the same infix operator for adding and concatenation, we are not so restricted when it comes to builtins. [1] https://docs.python.org/2/c-api/sequence.html#PySequence_Concat