[Tutor] Tuples, Dictionarys and mutable vs. immutable

Sheila King sheila@thinkspot.net
Sun, 25 Feb 2001 20:30:59 -0800


OK, now I'm really confused.

I don't really "get" the difference yet, between mutable and immutable types,
but I figured I would eventually get it. But at least I thought I understood
that an object could not change its type or its id. At least I thought I
understood that.

Then, explain this from my Python IDLE:
Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.6 -- press F1 for help
>>> mytuple = 'a', 'b', 'c'
>>> mytuple
('a', 'b', 'c')
>>> type (mytuple)
<type 'tuple'>
>>> mytyple = 'b'
>>> mytyple
'b'
>>> type (mytyple)
<type 'string'>
>>> mytuple = mytyple
>>> type (mytuple)
<type 'string'>
>>>  

mytuple is originally a tuple. And then I end up changing it to a string? I
thought this was not possible.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/