Newbie question about reference

Tim Smith tssmith at velocio.com
Sun Mar 23 01:48:40 CET 2003


"Terry Reedy" <tjreedy at udel.edu> wrote:
>You here bind 'list' to the object [1,2,3].  (Note: DON'T use builtin
>names as vars unless you have a positive reason for so doing.)

OK, I had thought that L = [x,y,z] was binding the list L as an
ordered set of references/pointers to the variables x, y, z. Obviously
not, as integers are, along with strings etc., immutable types. So
 >>>x = 1 #and
 >>>x = 2
would show two different pointers for x, the first one eventually
being gc'd. (?)

This is not clearly explained in the material I have read so far. It's
emphasized that strings are immutable, but not ints, tho' I suppose it
should be obvious, especially to one who's thinking in implementation
terms (I don't think that way :-). (And oh, I wouldn't use a builtin
name normally, but thanks for the warning.)





More information about the Python-list mailing list