[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Concerning copy



Kevin Turner wrote:

Recently I encountered an issue where Python would, instead of creating a new object, instead reference the original one. Using copy.copy() is a solution, but I'd much rather be able to toggle off the weird referencing that Python has been using and make exceptions as necessary. Is there any way to do this?


Python *always* references the original, unless you explicitly make a copy. This is a very
important thing to understand when learning Python. It's generally the "Right Thing" to
do, perhaps counter-intuitively.


Do some searches on "mutability", "mutable", "immutable", and "pass by object reference".

You should find some interesting discussions about this topic (which comes up at
least once a month on comp.lang.python, I'm pretty sure).


Cheers,
Terry

--
Terry Hancock (hancock@xxxxxxxxxxxxxxxxxxxx)
Anansi Spaceworks http://www.AnansiSpaceworks.com