Namespace Mystery (HELP!)
Greg Ewing
see at my.signature
Sun Jul 9 22:14:33 EDT 2000
If you're devious enough, it can be done (warning,
trying to understand how this works may cause
brain explosion):
def spam():
my_globals = {}
parrot = 'alive'
cmd = "global g; g = 42; parrot = 'resting'"
exec "exec cmd in my_globals, locals()"
print my_globals['g'], parrot
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list