New submission from Marco Buttu:
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.
----------
assignee: docs@python
components: Documentation
messages: 192805
nosy: docs@python, marco.buttu
priority: normal
severity: normal
status: open
title: sum() does not return only the sum of a sequence of numbers + PEP8
reccomandation
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18424>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com