What is module initialization?

dudeja.rajat at gmail.com dudeja.rajat at gmail.com
Tue Sep 2 16:32:07 CEST 2008


> While this is technically legal, you should restrain yourself from doing
> such a thing, unless you *really* know what you're doing and why.
>
>> but the variable is not getting updated in the module
>> containing global symbols ( variables).
>
> I suspect you didn't use a qualified name when importing. You have to do it
> this way :
>
> # myglobals.py:
> answer = 42
>
> # question.py
> import myglobals
> myglobals.answer = "WTF ?"
>

But if I do :-
#question.py
from myglobals import *
myglobals.answer = "WTF ?"

will this work?



More information about the Python-list mailing list