What is module initialization?

Fredrik Lundh fredrik at pythonware.com
Tue Sep 2 13:22:32 EDT 2008


dudeja.rajat at gmail.com wrote:

>> # 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?

with the above definition of myglobals, no.  "from myglobals import" 
doesn't add the module object to the importing module's namespace.

have you read:

http://effbot.org/zone/import-confusion.htm

?

</F>




More information about the Python-list mailing list