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

codeop.CommandCompiler

Up: codeop | Next: codeop.Compile
Rel: codeop.Compile, codeop.compile_command
Ref: docs.python.org — codeop.CommandCompiler
Tags: #public #python3 #stdlib #codeop


Import

import codeop
from codeop import CommandCompiler

Signature & Overview

codeop.CommandCompiler()

Instances of this class have call methods identical in signature to compile_command; the difference is that if the instance compiles program text containing a future statement,

Usage

import codeop

cc = codeop.CommandCompiler()
assert cc("x = 1 + 2") is not None
assert cc("def f():") is None

Gotchas

REPL Inspect

from codeop import CommandCompiler
help(CommandCompiler)

Linked from

Related notes