For dynamic execution of statements use the exec
function:
>>> exec('y = 3')
>>> y
3
eval
usage: eval(expression)
.
The expression
argument is parsed and evaluated as a Python expression.
e.g.:
>>> s = 3
>>> eval('s == 3')
True
>>> eval('s + 1')
4
>>> eval('s')
3
>>> eval('str(s) + "test"')
'3test'