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/2005-March/052141.html below:

[Python-Dev] Rationale for sum()'s design?

[Python-Dev] Rationale for sum()'s design? [Python-Dev] Rationale for sum()'s design?Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 14 01:22:25 CET 2005
Guido van Rossum wrote:
> 
> - the identity (defaulting to 0) if the sequence is empty
> - the first and only element if the sequence only has one element
> - (...(((A + B) + C) + D) + ...) if the sequence has more than one element

While this might be reasonable if the identity
argument is not specified, I think that if an
identity is specified, it should be used even
if the sequence is non-empty. The reason being
that the user might be relying on that to get
the semantics he wants.

Think of the second argument as "accumulator
object" rather than "identity".

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+
More information about the Python-Dev mailing list

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