Tuples and immutability
Eric Jacoboni
eric.jacoboni at gmail.com
Thu Feb 27 11:01:39 EST 2014
More information about the Python-list mailing list
Thu Feb 27 11:01:39 EST 2014
- Previous message (by thread): How to run multiple virtualenv in product server
- Next message (by thread): Tuples and immutability
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
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[1] += [20]
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[1] and a
tuple is immutable...
But, then, why a_tuple is still modified?
>>> a_tuple
('spam', [10, 30, 20], 'eggs')
I get a TypeError for an illegal operation, but this operation is still
completed?
- Previous message (by thread): How to run multiple virtualenv in product server
- Next message (by thread): Tuples and immutability
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list