TypeError expected in an augmented assignment
candide
c.candide at laposte.net
Wed Jul 2 22:39:47 EDT 2014
An hybrid list-tuple concatenation is not allowed
>>> []+(1, 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
>>>
hence I was expecting (*) that the following code raises a TypeError :
>>> x = []
>>> x += (1, 2)
>>> x
[1, 2]
>>>
Any explanation ?
(*) as the docs states, the augmented assignment is supposed to perform the concatenation :
An augmented assignment (...) performs the binary operation specific to the type of assignment on the two operands (...)
More information about the Python-list
mailing list