Are tuple really immutable?
tjreedy at udel.edu
Mon Dec 27 19:55:22 CET 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.append(0)
>> >>> t
>> ([1, 0], )
>> 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