namespace & imported modules
__peter__ at web.de
Wed Nov 24 09:10:59 CET 2004
> I've been having trouble understanding the difference between global
> namespace within and between modules. For example, I can program a
Did you know that global variables are only global to the module?
> from subfile import thread1, thread2 # this should be the only
This will bind the names thread1 and thread2 in the importing module, i. e.
you have now two distinct thread1 variables no longer pointing to the same
object after a thread1 = something assignment in one of the modules. Do
instead and access the variables with qualified names
subfile.thread1 = something
in all modules except subfile.py, and everything should be OK.
More information about the Python-list