Newbie question about reference

Tim Smith tssmith at velocio.com
Sat Mar 22 16:10:02 EST 2003


Something that this beginner does not understand about Python. Why
does the following--

 > python
 Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on
win32
 Type "help", "copyright", "credits" or "license" for more
information.
 >>> x = 1
 >>> y = 2
 >>> z = 3
 >>> list = [x, y, z]
 >>> list
 [1, 2, 3]
 >>> y = 0
 >>> list
 [1, 2, 3]
 >>>

do what it does? I expected the last "list" to return [1, 0, 3]. I've
looked through Mark Lutz's "Learning Python", and the FAQ, but haven't
found the answer. Probably missed it, but... Something about integers?
No, the behavior is the same for other types I've tried. (Compare the
example on p.64 in the Lutz book, which does what I expected.)





More information about the Python-list mailing list