Equivalent of TCL's "subst" ?

Loic Mahe loic.mahe at nospam.fr
Wed Nov 14 05:15:03 EST 2007


gamename a écrit :
> Hi,
> 
> 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?
> 
> TIA,
> -T
> 

you can also try using eval:

 >>> foobar = "HI!"
 >>> x = 'foo'
 >>> y = 'bar'
 >>> print eval(x+y)
HI!



Loic



More information about the Python-list mailing list