dynamic variables; globals

Randy Heiland heiland at ncsa.uiuc.edu
Wed Jan 22 08:13:38 EST 2003


Justin Shaw wrote:

> > 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

Thanks.  And if I want to use the RExec module instead?





More information about the Python-list mailing list