dynamic variables; globals
Wojtek Walczak
gminick at hacker.pl
Wed Jan 22 07:51:19 EST 2003
Dnia Wed, 22 Jan 2003 06:12:05 -0600, Randy Heiland napisał(a):
>>>> def func(sarg):
> ... exec(sarg)
> ...
>>>> func('foo=11')
>>>> func('print foo')
[...]
> Style & security notwithstanding, is there some way to add a dynamic
> variable to the globals list?
It's not too useful, but it works:
def blah(q):
exec(q)
blah('blah.func_globals["foo"]=11')
blah('print foo')
--
[ ] gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]
More information about the Python-list
mailing list