creating variable in root namespace from module

MakaMaka justin.frost at
Fri Mar 10 08:46:36 CET 2006

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:

some_module.afunction() # <== create a variable x1=1 and add it to the
scope of

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.


More information about the Python-list mailing list