Newbie References Question -> Exemple

Dennis Lee Bieber wlfraed at ix.netcom.com
Thu Sep 26 02:34:44 CEST 2002


Guy Rabiller fed this fish to the penguins on Wednesday 25 September 
2002 08:14 am:

> Ok,
> 
> thanks for your answers, I understand now that a variable name is
> 'just' a name in a dictionary, and not a container.
> 
> What I want to do is simple, and I suppose that this is my 'way of
> thinking' regarding Python that is wrong.
> 
> I have a list of points, and a list of polygons that should contain
> 'references' to points.
> 
> So for me:
> -> points list:
> p = []
> p.append([0,0])
> p.append([0,1])
> p.append([1,1])
> p.append([1,0])
> -> polygon:
> quad = []

        Created a /new/ list

> quad.append(p[0])

        appended the value of p[0] to the new list

> For me the quad list of point is not 'updated' with the change of one
> of its point.
>
        So just use

quad = p

which binds "quad" to the /same/ value that p is bound to.


        Strangely, I had the opposite problem two years ago, when trying to 
"save state" for small test set. I was using the simple assignment and 
finding that I wasn't saving the state but making a reference (your 
term) to it.

--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list