Steven D'Aprano wrote:
Normally this is harmless, but there is one interesting little glitch you
can get:
t = ('a', [23])
t[1] += [42]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
t
('a', [23, 42])
There is one other glitch, and possibly my only complaint:
--> a = [1, 2, 3]
--> b = 'hello, world'
--> a = a + b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "str") to list
--> a += b
--> a
[1, 2, 3, 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
IMO, either both + and += should succeed, or both should fail.
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list