Equivalent of TCL's "subst" ?
Steven Bethard
steven.bethard at gmail.com
Tue Nov 13 18:08:26 EST 2007
gamename wrote:
> In TCL, you can do things like:
> set foobar "HI!"
> set x foo
> set y bar
> subst $$x$y
> HI!
>
> Is there a way to do this type of evaluation in python?
If this is at the outer-most scope, you can use globals()::
>>> foobar = 'HI!'
>>> x = 'foo'
>>> y = 'bar'
>>> globals_dict = globals()
>>> globals_dict[x + y]
'HI!'
That said, why do you think you want to do this?
STeVe
More information about the Python-list
mailing list