On this page
code.compile_command
Up: code | Next: code.interact
Rel: code.interact, code.InteractiveConsole, code.InteractiveInterpreter
Ref: docs.python.org — code.compile_command
Tags: #public #python3 #stdlib #code
Import
import code
from code import compile_command
Signature & Overview
code.compile_command(source, filename='<input>', symbol='single', flags=0)
Compile a command and determine whether it is incomplete.
Usage
import code
assert code.compile_command("a = 1") is not None
assert code.compile_command("if True:") is None
Gotchas
- Returns
Nonefor incomplete statements and raisesSyntaxErrorfor invalid syntax.
REPL Inspect
from code import compile_command
help(compile_command)
Linked from
Related notes
- tuts/python3/stdlib_module/code/interact Linked here; links to this page; shared tags: #code, #stdlib
- tuts/python3/stdlib_module/code/InteractiveConsole Linked here; links to this page; shared tags: #code, #stdlib
- tuts/python3/stdlib_module/code/InteractiveInterpreter Linked here; links to this page; shared tags: #code, #stdlib
- tuts/python3/stdlib_module/code 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