[Tutor] Tuples, Dictionarys and mutable vs. immutable

Rick Pasotto rick@niof.net
Sun, 25 Feb 2001 23:49:53 -0500


On Sun, Feb 25, 2001 at 08:30:59PM -0800, Sheila King wrote:
> 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.

'mytuple' is a *name*. First it is the name of a tuple and then it is
the name of a string. "The map is not the territory." It is the *object*
that 'mytuple' names when it is the name of a tuple that is immutable.

-- 
"There is no more subtle means of transforming the basic concepts of
our government, or shifting from the preeminence of individual rights,
to the preeminence of government wishes, than is afforded by
redefinition of 'general welfare', as that term is used to define the
Government's power of seizures...  In essence the claim is that if
slums exist the Government may seize, redevelop & sell all the
property in any area it may select as appropriate, so long as the area
includes the slum area.  This amounts to a claim on the part of the
authorities for unreviewable power to seize & sell whole sections of
the city."
		-- DC District Court 1953
		   Rick Pasotto email: rickp@telocity.com