[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Problems with getting keyboard input.
On Tue, 25 Jun 2002, John Popplewell wrote:
> dont use 'is' when you mean '==' :-)
>
> So this :
>
> # Check for up arrow, exit loop if found.
> elif event.type is KEYDOWN and event.key is K_UP:
> print "got up!"
> Done = 1
>
> could be :
>
> # Check for up arrow, exit loop if found.
> elif event.type == KEYDOWN and event.key == K_UP:
> print "got up!"
> Done = 1
On the other hand, the Chimp tutorial itself uses 'is' in a lot of its
comparisons. For example, its main loop does:
###
if event.type is QUIT:
return
elif event.type is KEYDOWN and event.key is K_ESCAPE:
return
###
There's not a single '==' mentioned in the Chimp tutorial. I know 'is' is
done for efficiency's sake, when testing for identity is equivalent to
equality... yikes, that sentence came out awkwardly. *grin*
But for the Pygame tutorial, perhaps it might be better to use '=='
instead?
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org