Message239388
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. |
|
Date |
User |
Action |
Args |
2015-03-27 11:24:07 | vsinitsyn | set | recipients:
+ vsinitsyn, docs@python |
2015-03-27 11:24:06 | vsinitsyn | set | messageid: <1427455446.97.0.658394608092.issue23787@psf.upfronthosting.co.za> |
2015-03-27 11:24:06 | vsinitsyn | link | issue23787 messages |
2015-03-27 11:24:06 | vsinitsyn | create | |
|