interact() method, which repeatedly
calls raw_input(PyObject), and hence __builtin__#raw_input(PyObject), in order
to get lines, and push(String) them into the interpreter. The built-in
raw_input() method prompts on sys.stdout and reads from
sys.stdin, the standard console. These may be redirected using
setOut(java.io.OutputStream) and setIn(java.io.InputStream) , as may also
sys.stderr.
| Modifier and Type | Field and Description |
|---|---|
| public static String | CONSOLE_FILENAME
To work around an issue in javadoc with Java 8 we cannot have it final for now, see issue 2539 for details. |
| public String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | InteractiveConsole(PyObject
dictionary to use, or if locals)null, a new empty one will be createdConstruct an interactive console, which will "run" when |
| public | InteractiveConsole(PyObject
dictionary to use, or if locals, String null, a new empty one will be createdname with which to label this console input (e.g. in error messages). filename)Construct an interactive console, which will "run" when |
| public | InteractiveConsole(PyObject
dictionary to use, or if locals, String null, a new empty one will be createdname with which to label this console input filename, boolean if true, hook this class's replaceRawInput)raw_input into the built-ins.Full-feature constructor for an interactive console, which will "run" when
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public static String | Returns: the banner.Returns the banner to print before the first interaction:
" |
| public void | |
| public void | interact(String
to print before accepting input, or if banner, PyObject null, no banner.from which to read commands, or if file)null, read the console.Operate a Python console by repeatedly calling |
| public boolean | |
| public String | |
| public String |
| CONSOLE_FILENAME | back to summary |
|---|---|
| public static String CONSOLE_FILENAME Note This field is actually final; don't modify. To work around an issue in javadoc with Java 8 we cannot have it final for now, see issue 2539 for details. | |
| filename | back to summary |
|---|---|
| public String filename | |
| InteractiveConsole | back to summary |
|---|---|
| public InteractiveConsole() Construct an interactive console, which will "run" when | |
| InteractiveConsole | back to summary |
|---|---|
| public InteractiveConsole(PyObject locals) Construct an interactive console, which will "run" when
| |
| InteractiveConsole | back to summary |
|---|---|
| public InteractiveConsole(PyObject locals, String filename) Construct an interactive console, which will "run" when | |
| InteractiveConsole | back to summary |
|---|---|
| public InteractiveConsole(PyObject locals, String filename, boolean replaceRawInput) Full-feature constructor for an interactive console, which will "run" when
| |
| _interact | back to summary |
|---|---|
| public void _interact(String banner, PyObject file) | |
| getDefaultBanner | back to summary |
|---|---|
| public static String getDefaultBanner() Returns the banner to print before the first interaction:
"
| |
| interact | back to summary |
|---|---|
| public void interact() Operate a Python console, as in | |
| interact | back to summary |
|---|---|
| public void interact(String banner, PyObject file) Operate a Python console by repeatedly calling | |
| push | back to summary |
|---|---|
| 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()). | |
| raw_input | back to summary |
|---|---|
| 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. | |
| raw_input | back to summary |
|---|---|
| public String raw_input(PyObject prompt, PyObject file) Write a prompt and read a line from a file. | |