Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

4  
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) –  Lohoris Jan 31 '12 at 10:51

1 Answer 1

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: pygame.org/docs/ref/locals.html --> 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 *'. –  Lohoris Jan 31 '12 at 10:47

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