| Store | Cart

pygame question

From: jepler@unpythonic.net <jep...@unpythonic.net>
Thu, 11 Jul 2002 18:43:22 -0500
On Thu, Jul 11, 2002 at 05:58:18PM -0500, Michael Bauers wrote:
> I was curious as to why 'is K_SPACE' worked, but 'is K_r' did not.  I had to> change the test for 'r' to ==.> > * code snippet *>             elif (event.type is KEYDOWN and event.key is>                K_SPACE):>                 # DO SOMETHING>             elif (event.type is KEYDOWN and>                   event.key == K_r):>                # DO SOMETHING ELSE

If these are just ints, you should use ==, not 'is'.

'is' will work sometimes, and more often for small positive ints (they're
special).

>>> x = 1000>>> x is 1000
0
>>> x = 1       >>> x is 1
1

Jeff

Recent Messages in this Thread
Michael Bauers Jul 11, 2002 10:58 pm
jep...@unpythonic.net Jul 11, 2002 11:43 pm
Terry Reedy Jul 12, 2002 01:35 am
Michael Bauers Jul 12, 2002 02:32 am
Messages in this thread