Tuples and immutability
zachary.ware+pylist at gmail.com
Thu Feb 27 17:13:30 CET 2014
On Thu, Feb 27, 2014 at 10:01 AM, Eric Jacoboni <eric.jacoboni at gmail.com> wrote:
> I'm using Python 3.3 and i have a problem for which i've still not found
> any reasonable explanation...
>>>> a_tuple = ("spam", [10, 30], "eggs")
>>>> a_tuple += 
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: 'tuple' object does not support item assignment
> Ok... I accept this message as += is a reassignment of a_tuple and a
> tuple is immutable...
> But, then, why a_tuple is still modified?
> ('spam', [10, 30, 20], 'eggs')
> I get a TypeError for an illegal operation, but this operation is still
You're not the first person to have this question :)
More information about the Python-list