[noob question] References and copying
Boris Borcic
bborcic at gmail.com
Fri Jun 9 11:13:19 EDT 2006
zefciu wrote:
> 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.
It would if you had written "b[:]=[5,6]"
> 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?
not like that.
>
> Greets to all PyFans
> zefciu
More information about the Python-list
mailing list