Pythonic way to sum n-th list element?
revanna at mn.rr.com
Tue Apr 22 05:08:58 CEST 2003
On Mon, 21 Apr 2003 16:02:27 +0000, Alex Martelli wrote:
> As a bonus -- sum() now returns 0, while in my original design it raised
> a ValueError, just like e.g. max() does. I thought raising an error was
> best in the name of "errors shouldn't pass silently" and "in the face of
> ambiguity, refuse the temptation to guess". But -- once we decree that
> "sum is about numbers", there's no real ambiguity, so we can have the
> little extra handiness of having sum() not be an error;-).
Sum() is a goodness! And sum() returns 0 is a great goodness.
Just my $.03 worth,
More information about the Python-list