| Home | Trees | Index | Help |
|
|---|
| Module code :: Class InteractiveConsole |
|
InteractiveInterpreter --+
|
InteractiveConsole
TTYGuiClosely emulate the behavior of the interactive Python interpreter. This class builds on InteractiveInterpreter and adds prompting using the familiar sys.ps1 and sys.ps2, and input buffering.
| Method Summary | |
|---|---|
Constructor. | |
Closely emulate the interactive Python console. | |
Push a line to the interpreter. | |
Write a prompt and read a line. | |
Reset the input buffer. | |
| Inherited from InteractiveInterpreter | |
Execute a code object. | |
Compile and run some source in the interpreter. | |
Display the syntax error that just occurred. | |
Display the exception that just occurred. | |
Write a string. | |
| Method Details |
|---|
__init__(self,
locals=None,
filename='<console>')
|
interact(self, banner=None)Closely emulate the interactive Python console. The optional banner argument specify the banner to print before the first interaction; by default it prints a banner similar to the one printed by the real Python interpreter, followed by the current class name in parentheses (so as not to confuse this with the real interpreter -- since it's so close!). |
push(self, 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(self, prompt='')Write a prompt and read a line. 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. |
resetbuffer(self)Reset the input buffer. |
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Mon Jul 25 01:39:27 2005 | http://epydoc.sf.net |