How do I execute a string containing Python code in Python?
eval() is just for expressions, while eval('x+1') works, eval('x=1') won't work for example. In that case, it's better to use exec, or even better: try to find a better solution :)
eval()
eval('x+1')
eval('x=1')
exec