Tim Peters wrote:

I can't say it bothers me to specify an appropriate identity element
when 0 is inappropriate.

Maybe instead of a single sum() function, each summable type should have a sum() static method which uses an identity appropriate to that type.

So to sum a list of integers you would use int.sum(x),
to sum floats you would use float.sum(x), and to sum
timedeltas you would use timedelta.sum(x).

This would also neatly solve the problem of people
trying to sum strings, because there would be no
str.sum() method.

Or alternatively, there could be a str.sum(x) which
was equivalent to "".join(x). Although it might be
better to call it str.concat() instead of str.sum().

--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of USA Inc.  |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to