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

summing a bunch of numbers (or "whatevers")

[Python-Dev] Fwd: 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:29:28 +0200
On Monday 21 April 2003 09:06 am, Martin v. Löwis wrote:
> Guido van Rossum <guido@python.org> writes:
> > But still, what should sum([]) do?
>
> It should raise a ValueError("no values to sum"). In practice, I
> expect it won't matter, because users will typically have values to
> sum. If they don't, telling them to write sum(L or [0]) is easy
> enough. There should be preferably only one obvious way to do it.

I like this a lot -- particularly because it's exactly what I teach
people now for max and min (except that in the cases of max
and min there's the extra complication for the user of choosing
WHAT he or she wants as the result for an empty list, while in
the case of sum the user's life will be easier).


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