[docs] [issue18424] sum() does not return only the sum of a sequence of numbers + PEP8 reccomandation

Ronald Oussoren report at bugs.python.org
Wed Jul 10 16:04:42 CEST 2013

Ronald Oussoren added the comment:

There's an annoyingly long discussion about sum() on python-ideas.

IMHO the documentation should mention, as it does now, that sum is intended to be used with a sequence of numbers even it does work with most objects that support the + operator (such as by implementing __add__). In particular, using sum with a sequence of lists or tuples is extremely inefficient.

The fact that sum({1:'a', 2: 'b'}) works is a side effect of the how python works with sequences and IMHO doesn't have to be documented in every function that accepts a sequence as an argument.

nosy: +ronaldoussoren

Python tracker <report at bugs.python.org>

More information about the docs mailing list