[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")
Tim Peters
tim.one@comcast.net
Sun, 20 Apr 2003 23:29:35 -0400
[Aahz]
> Problem is, what *kind* of number? While ints are in general easily
> promotable (especially int 0), I'd prefer to make things explicit.
I'd be OK with changing the signature to
sum(iterable, empty=0)
as 0 cannot in fact be auto-promoted to some reasonable number-like objects.
For example, summing a list of datetime.timedelta objects seems a quite
natural application (e.g., picture a timesheet app), but supplying int 0
generally blows up when a timedelta is expected.