
On Mon, Oct 21, 2019 at 10:25:57AM -0500, Dan Sommers wrote:
Iterables are ordered collections of values, and outside of specialized subclasses, we can't expect that adding the values is meaningful or even possible.
Correct. That's why lists, tuples, strings, bytes and even arrays all define addition as concatentation rather than element-by-element addition. We leave it to specialised libraries and data types, like numpy, to implement element-by-element addition.
"Adding the values" is too specialized and not general enough for iterables.
Correct. That's why join is a specialised string method, rather than a method on more general lists.
And yet the builtin function sum exists and works the way it does.
Yes, because sum is a specialised function whose job is to sum the values of an iterable. What did you think it was, if it wasn't a specialised "sum these values" function? -- Steven