Reputation: 713
Hi everyone, i would like to know why this code works
from pygame.locals import *
print QUIT
and this don't works
import pygame
print pygame.locals.QUIT
Upvotes: 0
Views: 115
Reputation: 251508
You have to import pygame.locals
, not pygame
. Modules inside a package aren't automatically imported just because you import the package.
Upvotes: 0
Reputation: 1124000
locals
is a nested sub-package of pygame
, you'll have to import it first:
import pygame.locals
It is not an attibute of pygame
itself; that only works if the pygame/__init__.py
file itself were to do from . import locals
.
Upvotes: 1