30.2. codeop Python

: Lib/codeop.py


codeop code Python read-eval-print code

:

  1. Python: '>>>' '...'
  2. future

codeop

:

codeop.compile_command(source, filename="<input>", symbol="single")

Python source source Python '<input>' filename source Python PythonNone

source Python SyntaxError OverflowError ValueError

symbol source ('single' ) ('eval') ValueError

2API

class codeop.Compile

compile() __call__() __future__

class codeop.CommandCompiler

compile_command() __call__() __future__