[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Declaring variables in function as if at code's line-level



You can just declare your variables inside a function and their scope will only reach inside that function.

If you declare module variables (or global variables, if you fancy that name more) you can refer them inside functions without adding anything. But if you want to assig something to the variable (eg. Create an object) you must specify the global keyword at the beginning of the function.

Sorry if I didn't get the point of your question.

Ciro

El sábado 10 de marzo de 2012, Brian Brown <brobab@xxxxxxxxx> escribió:
> Hi pygame users, just a simple question-- How can one cause variables
> at "function-level" to behave like variables at "line-level"? (With
> basic python code) I just want to avoid using "global" over and over
> again (in many different functions) while I want to declare, use, and
> delete all my game's variables inside functions.Thanks.
> Matt
>