Message192805
The documentaion of sum():
Returns the sum of a sequence of numbers (NOT strings) plus the
value of parameter 'start' (which defaults to 0).
When the sequence is empty, returns start.
A. According to the PEP-8 it should be: "Return the sum...", and
"When the sequence is empty, return start.", like the other docs.
For instance:
>>> print(len.__doc__)
len(object) -> integer
Return the number of items of a sequence or mapping.
B. When the second argument is a tuple or a list, you can add sequences
of sequences:
>>> sum([['a', 'b', 'c'], [4]], [])
['a', 'b', 'c', 4]
>>> sum(((1, 2, 3), (1,)), (1,))
(1, 1, 2, 3, 1)
C. sum() takes not just sequences:
>>> sum({1: 'one', 2: 'two'})
3
Maybe it is not a good idea to give a complete description of sum() in the docstring, but perhaps something "good enough". In any case, I think the lack of the PEP-8 recommendation should be fixed. |
|
Date |
User |
Action |
Args |
2013-07-10 13:11:34 | marco.buttu | set | recipients:
+ marco.buttu, docs@python |
2013-07-10 13:11:34 | marco.buttu | set | messageid: <1373461894.57.0.746181395812.issue18424@psf.upfronthosting.co.za> |
2013-07-10 13:11:34 | marco.buttu | link | issue18424 messages |
2013-07-10 13:11:34 | marco.buttu | create | |
|