Python eval() built-in function

From the Python 3 documentation

The arguments are a string and optional globals and locals. If provided, globals must be a dictionary. If provided, locals can be any mapping object.

Examples

>>> eval('1 + 4')
# 5

>>> eval('print("Hello World!")')
# Hello World!

>>> x = 10
>>> eval('x == 10')
# True

Subscribe to pythoncheatsheet.org

Join 9.800+ Python developers in a two times a month and bullshit free publication , full of interesting, relevant links.