[noob question] References and copying

zefciu zefirek at Speacock.Pau.Apoznan.Mpl
Fri Jun 9 11:09:03 EDT 2006


Hello!

Where can I find a good explanation when does an interpreter copy the
value, and when does it create the reference.  I thought I understand
it, but I have just typed in following commands:

>>> a=[[1,2],[3,4]]
>>> b=a[1]
>>> b=[5,6]
>>> a
[[1, 2], [3, 4]]
>>> b
[5, 6]

And I don't understand it.  I thought, that b will be a reference to a,
so changing b should change a as well.  What do I do wrong.  And a
second question - can I create a reference to element of a list of
floating points and use this reference to change that element?

Greets to all PyFans
zefciu



More information about the Python-list mailing list