global vars?

Holger Jannsen holger at
Wed Jun 9 06:34:26 EDT 1999

Hi there,

I'm a newbie at python and there's something I don't understand:

I'd like to have some global variables e.g. PREDEFINED_PROGDIR.
It should have a predefined value e.g. "C:\\programs" in an
init-procedure. Then, there's a loop in another procedure, 
which reinitializes that variable every time calling that 
Also the loop creates every time a new instance of an class where 
is another procedure that could give another value to that variable 
e.g. "C:\\programs\\myprogram", so I want to work with that 
new value further until a new item of the loop occurs.
[Check it?]

Why do I have to declare that variable again as global in that
class-procedre (with :	global PREDEFINED_PROGDIR)?
If I don't do that the value of that variable outside of that 
procedure is the old one.
It seems that python takes a global variable inside a procedure
in a class but not outside.

What's about my "narf" in my brain?


More information about the Python-list mailing list