Newbie References Question -> Exemple
Guy Rabiller
grabiller at 3dvf.net
Wed Sep 25 12:00:20 EDT 2002
Yes, exactly.
I forgot that 'p' refere to nested lists :/
How shame..
Thanks a lot.
--
guy rabiller
3d animator / td
grabiller at 3dvf.net
http://grabiller.3dvf.net
Andrew Koenig wrote:
> Guy> But now, if I change the coordinate of one point:
> Guy> p[0] = [5,5]
> Guy> I will have:
>>>>> p
> Guy> [[5, 5], [0, 1], [1, 1], [1, 0]]
> Guy> but:
>>>>> quad
> Guy> [[0, 0], [0, 1], [1, 1], [1, 0]]
>
> That is because you are not changing the coordinates of the point; you
> are causing p[0]--the 0th element of p--to refer to a completely new
> point.
>
> If you wanted to change the coordinates of the point, you should
> have written this:
>
> p[0][0] = 5
> p[0][1] = 5
>
> or, more succinctly:
>
> p[0][:] = [5, 5]
>
> If you try this, I think you will get the behavior you want.
More information about the Python-list
mailing list