foobar = HI!
x = 'foo'
y = 'bar'
print eval(x+y)
HI!
Great! Thanks.
-T
--
http://mail.python.org/mailman/listinfo/python-list
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
--
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
--
http://mail.python.org/mailman/listinfo/python-list
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
gamename wrote:
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
myStore={}
myStore['foobar']=HI!
x='foo'
y='bar'
print myStore[x+y]
-Larry
--