0

I've copied the following code from a tutorial:

import pygame
import sys
from pygame.locals import *

pygame.init()

DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()

This code compiles, but PyCharm insists that QUIT is an "Unresolved reference". Replacing QUIT with pygame.locals.QUIT obvious gets rid of this, but I'm concerned that there's something wrong with the imports. Is it that, or is PyCharm just misbehaving?

Watercleave
  • 183
  • 9
  • `from pygame.locals import *` will put everything in your local namespace. Do you see the pygame.locals.quit in the output of locals()? –  Sep 06 '14 at 14:38
  • 1
    I guess the issue could be similar to [this one](http://stackoverflow.com/questions/25588642/pycharm-false-syntax-error-using-turtle/25588673#25588673). – alecxe Sep 06 '14 at 14:53
  • 1
    That it is, and the solution works. Much obliged. – Watercleave Sep 06 '14 at 15:08
  • Ok, I'll mark as duplicate then. Thanks. – alecxe Sep 06 '14 at 15:43

0 Answers0