passing globals to imported module
jtauber at jtauber.com
Mon Aug 16 21:00:05 CEST 2004
Had a question from a colleague that I embarrassingly couldn't answer.
He has a script, foo.py with a global. He wants to import bar.py and
needs that global available in bar.py
The following obviously doesn't work:
my_global = "hello"
and results in:
['__builtins__', '__name__', '__doc__', 'my_global']
['__builtins__', '__name__', '__file__', '__doc__']
I'm not sure how to reimplement __import__ to make the global available
to the imported module.
James Tauber http://jtauber.com/
journeyman of some http://jtauber.com/blog/
More information about the Python-list