Class InteractiveConsole

  extended by org.python.util.PythonInterpreter
      extended by org.python.util.InteractiveInterpreter
          extended by org.python.util.InteractiveConsole
Direct Known Subclasses:
JLineConsole, ReadlineConsole

public class InteractiveConsole
extends InteractiveInterpreter

Field Summary
 String filename
Fields inherited from class org.python.util.InteractiveInterpreter
Constructor Summary
InteractiveConsole(PyObject locals)
InteractiveConsole(PyObject locals, String filename)
InteractiveConsole(PyObject locals, String filename, boolean replaceRawInput)
Method Summary
static String getDefaultBanner()
 void interact()
          Closely emulate the interactive Python console.
 void interact(String banner, PyObject file)
 boolean push(String line)
          Push a line to the interpreter.
 String raw_input(PyObject prompt)
          Write a prompt and read a line from standard input.
 String raw_input(PyObject prompt, PyObject file)
          Write a prompt and read a line from a file.
Methods inherited from class org.python.util.InteractiveInterpreter
interrupt, resetbuffer, runcode, runsource, runsource, runsource, showexception, write
Methods inherited from class org.python.util.PythonInterpreter
cleanup, compile, compile, compile, compile, eval, eval, exec, exec, execfile, execfile, execfile, get, get, getLocals, getSystemState, initialize, set, set, setErr, setErr, setErr, setIn, setIn, setIn, setLocals, setOut, setOut, setOut, threadLocalStateInterpreter
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final String CONSOLE_FILENAME
See Also:
Constant Field Values


public String filename
Constructor Detail


public InteractiveConsole()


public InteractiveConsole(PyObject locals)


public InteractiveConsole(PyObject locals,
                          String filename)


public InteractiveConsole(PyObject locals,
                          String filename,
                          boolean replaceRawInput)
replaceRawInput - - if true, we hook this Class's raw_input into the builtins table so that clients like cmd.Cmd use it.
Method Detail


public void interact()
Closely emulate the interactive Python console. The optional banner argument specifies the banner to print before the first interaction; by default it prints "Jython on ".


public static String getDefaultBanner()


public void interact(String banner,
                     PyObject file)


public boolean push(String line)
Push a line to the interpreter. The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter's runsource() method is called with the concatenated contents of the buffer as source. If this indicates that the command was executed or invalid, the buffer is reset; otherwise, the command is incomplete, and the buffer is left as it was after the line was appended. The return value is 1 if more input is required, 0 if the line was dealt with in some way (this is the same as runsource()).


public String raw_input(PyObject prompt)
Write a prompt and read a line from standard input. The returned line does not include the trailing newline. When the user enters the EOF key sequence, EOFError is raised. The base implementation uses the built-in function raw_input(); a subclass may replace this with a different implementation.


public String raw_input(PyObject prompt,
                        PyObject file)
Write a prompt and read a line from a file.

Jython homepage