The code
module provides facilities to implement
read-eval-print loops in Python. Two classes and convenience
functions are included which can be used to build applications which
provide an interactive interpreter prompt.
'__name__'
set to '__console__'
and key '__doc__'
set to None
.
sys.ps1
and sys.ps2
, and
input buffering.
source is the source string; filename is the optional
filename from which source was read, defaulting to '<input>'
;
and symbol is the optional grammar start symbol, which should
be either 'single'
(the default) or 'eval'
.
Returns a code object (the same as compile(source,
filename, symbol)
) if the command is complete and
valid; None
if the command is incomplete; raises
SyntaxError if the command is complete and contains a
syntax error, or raises OverflowError or
ValueError if the command cotains an invalid literal.