On this page
compile
Prev: classmethod | Up: __builtins__ | Next: complex
Rel: breakpoint, eval, exec, globals, input
Ref: docs.python.org — compile
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import compile
Overview & Signature
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1, *, _feature_version=-1)
Compile source into a code object that can be executed by exec() or eval().
Usage
expr = compile("2 ** 10", "<demo>", "eval")
assert eval(expr) == 1024
Gotchas
- Three modes:
"eval"(single expression),"exec"(module/statements), and"single"(interactive REPL statement).
REPL Inspect
help(compile)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/breakpoint
- tuts/python3/__builtins__/classmethod
- tuts/python3/__builtins__/complex
- tuts/python3/__builtins__/eval
- 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__/classmethod Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/complex Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/eval 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