What is module initialization?

dudeja.rajat at gmail.com dudeja.rajat at gmail.com
Tue Sep 2 21:21:29 CEST 2008


On Tue, Sep 2, 2008 at 6:22 PM, Fredrik Lundh <fredrik at pythonware.com> wrote:
> 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>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Thanks for your help guys that I got my problem resolved.



Regards,
Rajat



More information about the Python-list mailing list