[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pygame] Variables linking to eachother



The thing is I am actually am making a copy of an object, ala Copy Paste, is there a better way?

> 
> > If you want to assign a copy of an object to an other object and have the
> > two refer to different copies of that original object, use the
> > copy.deepcopy() function to generate a copy, i.e
> >
> > import copy
> > platformList.insert(1, copy.deepcopy(platformList[selectedPlatform]))
> 
> As a sidenote, if you find yourself needing to copy or deepcopy objects,
> you are probably doing something wrong design-wise. I can't remember a
> single Python program offhand that would've required copying objects.
> 
> Variables are references instead of values for a purpose.
> 
> --
> Sami Hangaslammi
> 

-- 
______________________________________________
http://www.linuxmail.org/
Now with e-mail forwarding for only US$5.95/yr

Powered by Outblaze