On Tue, Jan 28, 2014 at 12:28 AM, spir <denis.s...@gmail.com> wrote:

> <snip>
>
>  a = [1, [1,2]]
>>>> b = a
>>>> b
>>>>
>>> [1, [1, 2]]
>
>> b is a
>>>>
>>> True
>
> a's and b's values are a single, unique object... as long as I only
> modified them (the values) partly:
>
>  a = [1,[2,3]]
>>>> a[0] = 0
>>>> b
>>>>
>>> [0, [1, 2]]                  # this is where I get lost.
>
>> a[1] = [0,0]
>>>> b
>>>>
>>> [0, [0, 0]]
>
>> a is b
>>>>
>>> True
>
>  a[0] = b[0]
>>>> a[0] is b[0]
>>>>
>>> True
> <snip>
>
> denis



My python gets a different result:

 >>> a=[1,[1,2]]
>>> b=a
>>> b
[1, [1, 2]]
>>> a=[1,[2,3]]  # this breaks the connection.
>>> a[0]=0
>>> b
[1, [1, 2]]
>>> a[1]=[0,0]
>>> b
[1, [1, 2]]
>>>

What is going on?  I am more confused than I was a week ago.

-Denis H
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to