How do I execute a string containing Python code in Python?
The most logical solution would be to use the built-in eval() function .Another solution is to write that string to a temporary python file and execute it.