creating variable in root namespace from module
MakaMaka
justin.frost at gmail.com
Fri Mar 10 02:46:36 EST 2006
Hi,
I have a scope related question that I haven't been able to find an
answer to anywhere. Is there a way to have a function in an imported
module add variables to the scope of the calling script? Basically,
can I have the following:
#root.py
import some_module.py
some_module.afunction() # <== create a variable x1=1 and add it to the
scope of root.py
print x1 # <== would print 1
I know this can be accomplished by passing the what globals() returns
into the function; however, I'm wondering if there is a way to do this
without passing anything to the function.
Thanks!
More information about the Python-list
mailing list