Module code
[hide private]
[frames] | no frames]

Module code

Utilities needed to emulate Python's interactive interpreter.

Classes [hide private]
InteractiveInterpreter
Base class for InteractiveConsole.
InteractiveConsole
Closely emulate the behavior of the interactive Python interpreter.
Functions [hide private]
 
compile_command(source, filename='<input>', symbol='single')
Compile a command and determine whether it is incomplete.
 
softspace(file, newvalue)
 
interact(banner=None, readfunc=None, local=None)
Closely emulate the interactive Python interpreter.

Imports: sys, traceback, CommandCompiler


Function Details [hide private]

compile_command(source, filename='<input>', symbol='single')

 
Compile a command and determine whether it is incomplete.

Arguments:

source -- the source string; may contain \n characters
filename -- optional filename from which source was read; default
            "<input>"
symbol -- optional grammar start symbol; "single" (default) or "eval"

Return value / exceptions raised:

- Return a code object if the command is complete and valid
- Return None if the command is incomplete
- Raise SyntaxError, ValueError or OverflowError if the command is a
  syntax error (OverflowError and ValueError can be produced by
  malformed literals).

interact(banner=None, readfunc=None, local=None)

 

Closely emulate the interactive Python interpreter.

This is a backwards compatible interface to the InteractiveConsole class. When readfunc is not specified, it attempts to import the readline module to enable GNU readline if it is available.

Arguments (all optional, all default to None):

banner -- passed to InteractiveConsole.interact() readfunc -- if not None, replaces InteractiveConsole.raw_input() local -- passed to InteractiveInterpreter.__init__()