Mar-09-2019, 05:33 PM
eval() cannot evaluate a statement with an equal sign in it. The interpreter is understanding "e = ..." as assigning the keyword argument "e" to the value of "x + y + x".
from sympy.abc import x, y code = """ x + y + x """ try: e = eval(code) except SyntaxError: print("Hello")