Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I downloaded a game off pydev and the imports for it look like this below.

import pygame
from pygame.locals import *

However I have only ever created games by calling the in this way.

import pygame
import player
import enemy

I have called in the class one by one.

What does the lines of code at the top do? does it call all of his classes in?

share|improve this question

closed as off topic by sam hocevar, Josh Petrie, Tetrad Jan 31 '12 at 17:43

Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

This question would belong to stackoverflow, but I am afraid it does not seem like you even did any basic research. – sam hocevar Jan 31 '12 at 10:45
@SamHocevar: as it is it would belong to SO, but now he is also asking what pygame.locals does, which belongs here. (even there he did no research, though) – o0'. Jan 31 '12 at 10:51

It imports all public objects from pygame.locals into your module, so that you can use them directly instead of having to refer to them as pygame.locals.whatever.

share|improve this answer
Thanks for your answer, but what does locals mean exactly? like the classes? – Richard Gibbons Jan 31 '12 at 10:42
@RichardGibbons: --> This module contains various constants used by Pygame. Its contents are automatically placed in the pygame module namespace. However, an application can use pygame.locals to include only the Pygame constants with a 'from pygame.locals import *'. – o0'. Jan 31 '12 at 10:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.