On this page
  1. compile
  2. Import & Availability
  3. Overview & Signature
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

help(compile)

Linked from

Related notes