30.1. code

: Lib/code.py


code read-eval-print (--)Python

class code.InteractiveInterpreter(locals=None)

()() locals '__name__' '__console__' '__doc__' None

class code.InteractiveConsole(locals=None, filename="<console>")

Python InteractiveInterpreter sys.ps1 sys.ps2

code.interact(banner=None, readfunc=None, local=None, exitmsg=None)

read-eval-print InteractiveConsole readfunc InteractiveConsole.raw_input() local InteractiveConsole interact() banner exitmsg

3.6 : exitmsg .

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

Python(read-eval-print)()

source filename '<input>' symbol 'single' () 'eval'

(compile(source, filename, symbol) ) None SyntaxError OverflowError ValueError

30.1.1.

InteractiveInterpreter.runsource(source, filename="<input>", symbol="single")

compile_command() filename '<input>' symbol 'single' :

sys.ps1 sys.ps2

InteractiveInterpreter.runcode(code)

showtraceback() SystemExit

KeyboardInterrupt

InteractiveInterpreter.showsyntaxerror(filename=None)

filename Python '<string>' write()

InteractiveInterpreter.showtraceback()

write()

3.5 :

InteractiveInterpreter.write(data)

(sys.stderr)

30.1.2.

InteractiveConsole InteractiveInterpreter

InteractiveConsole.interact(banner=None, exitmsg=None)

Python banner Python (!)

exitmsg exitmsg None

3.4 :

3.6 :

InteractiveConsole.push(line)

runsource() True False ( runsource() )

InteractiveConsole.resetbuffer()

InteractiveConsole.raw_input(prompt="")

EOF EOFError sys.stdin