On this page
codeop.compile_command
Prev: codeop.Compile | Up: codeop
Rel: codeop.CommandCompiler, codeop.Compile
Ref: docs.python.org — codeop.compile_command
Tags: #public #python3 #stdlib #codeop
Import
import codeop
from codeop import compile_command
Signature & Overview
codeop.compile_command(source, filename='<input>', symbol='single', flags=0)
Compile a command and determine whether it is incomplete.
Usage
import codeop
assert codeop.compile_command("y = 42") is not None
assert codeop.compile_command("for i in range(3):") is None
Gotchas
- Compiles only—does not execute: Compound blocks require a trailing blank line (
"\n") to be considered complete.
REPL Inspect
from codeop import compile_command
help(compile_command)
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 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