creating variable in root namespace from module
MakaMaka
justin.frost at gmail.com
Fri Mar 10 13:19:32 EST 2006
Ok, I figured it out. Thanks for your help guys. If anybody else is
searching this group looking for the answer, you want the
sys._getframe() function.
sys._getframe(1).f_locals['a'] = 1
if you put the above in a function in a module, it creates a variable
'a' in the namespace of whatever calls the function in the module. I
know this may make people cringe, but since I'm trying to basically
create a language, of which python is a subset, it's actually exactly
what I need to do.
-Justin
More information about the Python-list
mailing list