dynamic variables; globals

Justin Shaw wyojustin at hotmail.com
Wed Jan 22 07:31:30 EST 2003


> Style & security notwithstanding, is there some way to add a dynamic
> variable to the globals list?

Quick answer:

>>> def func(sarg):
             exec(sarg, globals())

>>> func('foo=11')
>>> func('print foo')
11

Justin Shaw







More information about the Python-list mailing list