How to Lock Global Variables across Modules?

William Djaja Tjokroaminata billtj at y.glue.umd.edu
Mon Sep 25 13:03:11 EDT 2000


Hi,

I am having the problem to lock global variables across modules.  Suppose,
in module1 I have the global variable 'globvar_mod1'.  I have a second
module, module2, in which I have 'from module1 imports *' and
'import module1'.  Now, in module2,

    globvar_mod1            refers to the initial value of the variable
    module1.globvar_mod1    refers to the current value of the variable

Is there any way I can refer to the current value of the global variable
without using the long, explicit, name?  Putting something like
'gv = module1.globvar_mod1' in module2 does not work.  How can I have the
gloval variable in module2 to lock to the one in module1?  I think
basically what I want is something like C++ or Perl variable
reference.  Thanks.

Regards,

Bill



More information about the Python-list mailing list