On this page
eval
Prev: enumerate | Up: __builtins__ | Next: exec
Rel: breakpoint, compile, exec, globals, input
Ref: docs.python.org — eval
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import eval
Overview & Signature
eval(source, /, globals=None, locals=None)
Evaluate the given source in the context of globals and locals.
Usage
assert eval("3 * (4 + 5)", {"__builtins__": {}}, {}) == 27
Gotchas
- Never run
eval()on untrusted input: Even clearing__builtins__is NOT a security sandbox—useast.literal_eval()for Python literals orjson.loads()for structured data.
REPL Inspect
help(eval)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/breakpoint
- tuts/python3/__builtins__/compile
- tuts/python3/__builtins__/enumerate
- tuts/python3/__builtins__/exec
- tuts/python3/__builtins__/globals
- tuts/python3/__builtins__/input
- tuts/python3/__builtins__/locals
- tuts/python3/__builtins__/open
- tuts/python3/__builtins__/print
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/breakpoint Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/compile Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/enumerate Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/exec Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/globals Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/input Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/locals links to this page; shared tags: #builtins
- tuts/python3/__builtins__/open links to this page; shared tags: #builtins