[docs] [issue23787] sum() function docstring lists arguments incorrectly

Valentine Sinitsyn report at bugs.python.org
Fri Mar 27 12:24:07 CET 2015


New submission from Valentine Sinitsyn:

sum() function doctstring describes expected arguments as follows (Python 2.7.6):

sum(...)
    sum(sequence[, start]) -> value
...

This implies sum() should accept str, unicode, list, tuple, bytearray, buffer, and xrange. However, you clearly can't use this function to sum strings (which is also mentioned in the docstring):

>>> sum('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

I'd suggest to describe first argument as iterable, which is actually what sum() expects there.

----------
assignee: docs at python
components: Documentation
messages: 239388
nosy: docs at python, vsinitsyn
priority: normal
severity: normal
status: open
title: sum() function docstring lists arguments incorrectly
type: enhancement
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23787>
_______________________________________


More information about the docs mailing list