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/034845.html below:

summing a bunch of numbers (or "whatevers")

[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")Alex Martelli aleax@aleax.it
Mon, 21 Apr 2003 10:52:55 +0200
On Monday 21 April 2003 02:58 am, Guido van Rossum wrote:
   ...
> anything except sum([]) == 0, since they probably want to sum a list
> of numbers, and occasionally (albeit through a bug in their program
> :-) the list will be empty.  But that means that summing a sequence of

Errors should never pass silently, unless explicitly silenced.  I thus think
that the sum of an empty sequence should raise a ValueError (just
like the max or min of an empty sequence) and the idiom sum(L or [0])
should be taught to "sum up a list of numbers that might be empty".

> strings ends up with a strange end case.  So perhaps raising an
> exception for an empty sequence, like min() and max(), is better: "In
> the face of ambiguity, refuse the temptation to guess."  An optional

Yes!

> Alex, care to send in your patch?

Aye aye, cap'n -- now that youve crossed the i's and dotted the t's
I'll arrange the complete patch with tests and docs and submit it
forthwith.


Alex




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