Newbie References Question -> Exemple
Andrew Koenig
ark at research.att.com
Wed Sep 25 11:43:15 EDT 2002
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.
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list