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

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

REPL Inspect

from codeop import compile_command
help(compile_command)

Linked from

Related notes