Denis Heidtmann wrote:

> Running python 2.7 in linux
> 
> Below are two extremes.  Can I get some guidance on this?

>>>> a=zeros((2,3),dtype=int)
>>>> b=a
>>>> a[:,0]=[1,2]
>>>> a
> array([[1, 0, 0],
>        [2, 0, 0]])
>>>> b
> array([[1, 0, 0],
>        [2, 0, 0]])
>>>> a=2
>>>> a
> 2
>>>> b
> array([[1, 0, 0],
>        [2, 0, 0]])

In short:

x = ...

binds a name, it never copies. On the other side

x[whatever] = ...
or
x.attr = ...

can run arbitrary code that may or may not alter the object bound to x 
inplace. You have to know the type of x to know what happens.

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

Reply via email to