New submission from Björn Augustsson <ogg...@gmail.com>: Summary: "sum()" doesn't work on lists, even though the docs says it should.
The docs say: "Note that sum(range(n), m) is equivalent to reduce(operator.add, range(n), m)" That's not true. -------------------------------- import operator a=[1,2] b=["x","y"] reduce(operator.add, [a,b]) # Works, gives "[1, 2, 'x', 'y']" as expected. sum ([a,b]) # Does not work, gives: "TypeError: unsupported operand type(s) for +: 'int' and 'list'" -------------------------------- (And "a + b" obviously works too.) /August. ---------- components: None messages: 94275 nosy: oggust severity: normal status: open title: sum() doesn't work for lists. type: behavior versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7176> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com