unexpected behavior: did i create a pointer?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Sep 13 00:54:26 EDT 2007


En Wed, 12 Sep 2007 08:30:14 -0300, Bruno Desthuilliers  
<bruno.42.desthuilliers at wtf.websiteburo.oops.com> escribi�:

> neoedmund a écrit :
>> On Sep 7, 4:07 pm, gu <pistacc... at gmail.com> wrote:
> (snip pb and code)
>>> now, in the second "for" cycle and in functionA() i only 'touch'  
>>> copyOfA
>>> (altering it). as i don't touch the variable "a", i expect it not to be
>>> affected by any change, but copyOfA acts like a pointer to a and
>>> altering copyOfA's values result in altering the values of "a", so the
>>> result that i expect is:
> (snip)
>> no language act like want you tought, or the assignment operation will
>> be too expensive.
>
> IIRC, php4 was doing copies for arrays...

Pascal does copy arrays and structs (records) too.

-- 
Gabriel Genellina




More information about the Python-list mailing list