Are tuple really immutable?
Terry Reedy
tjreedy at udel.edu
Mon Dec 27 13:55:22 EST 2004
> Chris <chris.monnet at gmail.com> wrote:
> ...
>> 3) In this example, is t considered mutable or not?
>> "Tuple are immutable" says the doc, but:
>> >>> t[0].append(0)
>> >>> t
>> ([1, 0], [2])
>>
>> The tuple is immutable but its elements can be mutable: I tend to think
>> that it means that the tuple is mutable. Indeed, it changed!
No, not in the way intended by the word 'mutable'. A tuple is like an
ordered club roster written in indelible ink before the time of whiteout.
The members of the club may change (change jobs, residence, relationships,
etc) but the roster remains the same: same members, same ranking.
Terry J. Reedy
More information about the Python-list
mailing list