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

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

REPL Inspect

from code import compile_command
help(compile_command)

Linked from

Related notes