How to Lock Globar Variables across Modules?

Alex the_brain at
Thu Sep 28 15:58:37 CEST 2000

> I wish python had a reference feature to make it more efficient:
>     sv& =
> Whatever '' points to, 'sv' will also point to.  If
> possible in the implementation, hopefully a reference like this will
> not involve a dictionary look-up at all.

Sorry, python just doesn't work this way at the moment.  I think you
would have to change variable name lookups to check for such
'privileged' names.  That may or may not involve a lot of work.

One thing that I do to avoid having to import commonly used objects in
every module that uses them is modify the python __builtins__ module.
In main_module, you could do something like

import main_module
__builtins__.m = main_module

...and from then on, you could refer to sv as throughout your
program.  It still seems like a bad idea to me on the face of it,


Speak softly but carry a big carrot.

More information about the Python-list mailing list