Should I use pygame.event.get() or pygame.event.poll()?

event-handling, pygame, python

Solution

`get()` retrieves all events currently in the queue, and is usually used in a loop:

for event in pygame.event.get():
    # use event

`poll()` retrieves only a single event:

event = pygame.event.poll()
# use event

In the latter, you will need to explicitly check whether the type of event is a `pygame.NOEVENT`; in the former, the loop simply won't run if there are no events.

Generally, it is more common to use the `get()` version.

Problem

I'm making an application in pygame and I need to process events. I never really understood whether I should use `pygame.event.get()` or `pygame.event.poll()`, or if it really matters. Question: Should I use `pygame.event.get()` or `pygame.event.poll()`?

Original source