[Edu-sig] Getting it going
Fri, 4 Feb 2000 09:44:29 -0500
I haven't introduced myself yet, and I'm not addressing a very central
> * how to explain things in books, lik a variable is a box with a
> sticker on it, a dictionairy is a... a class is a...
A variable in Python isn't a box with a sticker on it, it's just a sticker.
You can stick multiple stickers on the same thing, but there is still only
one of the thing. This matters when the object is mutable:
a =  # a list  with the sticker "a" on it
b = a # now the list has stickers "a", "b" on it
a = 4 # the list is mutated to 
# and still has stickers "a", "b"
print a # 
print b # 
This is extraordinarily hard to explain with variables as boxes. How can I
put one object in two boxes, neither of which contains the other?
Of course, you can explain Python's semantics with boxes with stickers
containing pointers, but that's a rather needlessly complicated approach!