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

Re: [pygame] Sticky Variables



Bob Ippolito wrote:
> On 5/27/07, Kris Schnee <kschnee@xxxxxxxxxx> wrote:
>> But is there a better way to make it clear I want the value, not an
>> actual reference?
> 
> There are no values in Python, just references. Either you want an
> existing reference, or a new one. If you want a new one, then copying
> is usually appropriate.

I would argue that there are values, or else what do you have
references to?

The crucial point, though, is that assignment creates new references
to old objects, and that if you want new objects, you need to copy
(using deepcopy or otherwise). Fetching an object from a dict returns
an old object.

I'm interested in the curious use case Kris posts -- checking for
object identity as part of a sea adventure? I can only imagine. :)

Ethan

Attachment: signature.asc
Description: OpenPGP digital signature