A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/034838.html below:

summing a bunch of numbers (or "whatevers")

[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")Aahz aahz@pythoncraft.com
Sun, 20 Apr 2003 23:34:38 -0400
On Sun, Apr 20, 2003, Tim Peters wrote:
> [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.

+1

That makes the canonical usage clear, while not preventing people from
doing stupid things.  ;-)
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4