On this page
codeop.Compile
Prev: codeop.CommandCompiler | Up: codeop | Next: codeop.compile_command
Rel: codeop.CommandCompiler, codeop.compile_command
Ref: docs.python.org — codeop.Compile
Tags: #public #python3 #stdlib #codeop
Import
import codeop
from codeop import Compile
Signature & Overview
codeop.Compile()
Instances of this class behave much like the built-in compile function, but if one is used to compile text containing a future statement, it "remembers" and compiles all subsequent program texts
Usage
import codeop
c = codeop.Compile()
code_obj = c("1 + 1", "<mem>", "eval")
assert eval(code_obj) == 2
Gotchas
- Stateful wrapper around
compile()that tracks__future__imports across inputs.
REPL Inspect
from codeop import Compile
help(Compile)
Linked from
Related notes
- tuts/python3/stdlib_module/codeop/CommandCompiler Linked here; links to this page; shared tags: #codeop, #stdlib
- tuts/python3/stdlib_module/codeop/compile_command Linked here; links to this page; shared tags: #codeop, #stdlib
- tuts/python3/stdlib_module/codeop Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib