Nicko van Someren wrote:
>       >>> sum(['a','b','c'])
>       Traceback (most recent call last):
>         File "<stdin>", line 1, in <module>
>       TypeError: unsupported operand type(s) for +: 'int' and 'str'
>       >>> sum([["a"],[u'b'],[3]])
>       Traceback (most recent call last):
>         File "<stdin>", line 1, in <module>
>       TypeError: unsupported operand type(s) for +: 'int' and 'list'

You can already make the second example work properly by supplying an 
appropriate starting value:

 >>> sum([["a"],[u'b'],[3]], [])
['a', u'b', 3]

(and a similar call will also work for the new bytes type, as well as 
other sequences)

Strings are explicitly disallowed (because Guido doesn't want a second 
way to spell ''.join(seq), as far as I know):

 >>> sum(['a','b','c'], '')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: sum() can't sum strings [use ''.join(seq) instead]

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to