[docs] sum()
bob gailer
bgailer at gmail.com
Thu Dec 6 17:15:54 CET 2012
Currently:
sum(iterable[, start])
Sums start and the items of an iterable from left to right and returns
the total. start defaults to 0. The iterable‘s items are normally
numbers, and the start value is not allowed to be a string
I just learned that
sum([[1,2],[3,4]],[])
produces:
[1, 2, 3, 4]
I would never have guessed that from the explanation above! I think the
terms "sum" and "total" are misleading.
apply(operator.add, [[1,2], [3,4]]) generates the same result, but
emphasizes the use of +.
I suggest either explaining this explicitly or providing an example.
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the docs
mailing list