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

Re: [pygame] Re: Pygame not handling keyboard tracking correctly



On lun, 2014-06-23 at 02:45 -0400, Noel Garwick wrote:
> Im curious why "is" is bad in this case, as well. It's a constant;
> isn't that a good use for is, whether it's referring to an int or not?
> I tend to do this for event handling.  Maybe ints are always pointers
> in python?

I was just about to say this too. I assume if a library is exposing
constants to me, that the library uses those constants internally, using
direct references. So, the value is always a reference to the actual
constant, meaning I can be sure that it is always the constant object
itself, and not just an equal value. That is, if:
        event.type is EVENT
returns False, I can be sure it is not that event type, even if they
happened to be equal in value.

Having flicked through the code, this would appear to be correct. Pygame
gets it constants directly from the SDL constants, and the events in SDL
directly use the constants and not arbitrary ints.

Attachment: signature.asc
Description: This is a digitally signed message part