How to Lock Globar Variables across Modules?

Aahz Maruch aahz at panix.com
Wed Sep 27 01:11:20 EDT 2000


In article <8qnqpa$p4f$1 at hecate.umd.edu>,
William Djaja Tjokroaminata  <billtj at y.glue.umd.edu> wrote:
>
>I am having this problem.  Suppose in 'module1.py' I declare a global
>variable named 'globvar_mod1'.  In another module, called 'module2.py', I
>have the statement 'from module import *'.
>
>It looks like when I am running the program, the global variable in code
>in module2 only refers to the initial value in module1, unless I use an
>explicit name.  

"Doctor, it hurts when I bang my head into the wall."
"Well, then, don't do that."

Same principle applies here.  What you're trying to do doesn't fit well
with Python's model -- nor does it fit well with good programming style.
If you explain what your goal is, we may be able to give a better way to
accomplish it.  Meanwhile, I suggest you stick with module.var_name.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien



More information about the Python-list mailing list