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. Indeed it cannot *practically* be the most efficient or accurate to sum arbitrary objects, unless we manage to devise a clever protocol (__sum__? how would that work?) that can delegate to arbitrary third-party code. But people are bound to think, legitimately, that built-in sum() is the logical answer when wanting to sum a sequence of objects. (of course, whether or not "sum" is a reasonable notion when applied to strings - rather than lists or floats - is a separate question) Regards Antoine.