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

RE: [pygame] Variables linking to eachother



> 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