Inheritance diagram for IPython.kernel.core.interpreter:
Central interpreter object for an IPython engine.
The interpreter is the object whose job is to process lines of user input and actually execute them in the user’s namespace.
An interpreter object.
fixme: needs to negotiate available formatters with frontends.
Important: the interpeter should be built so that it exposes a method for each attribute/method of its sub-object. This way it can be replaced by a network adapter.
Complete the given text.
Pass an error message back to the shell.
|Parameters :||text : str|
This should only be called when self.message is set. In other words, when code is being executed.
Execute some IPython commands.
commands : str
message : dict
Execute a single block of code in the user namespace.
Return value: a flag indicating whether the code to be run completed successfully:
- 0: successful execution.
- 1: an error occurred.
Execute the value of a macro.
|Parameters :||macro : Macro|
Actually run the Python code in the namespace.
Compile some source in the interpreter.
One several things can happen:
1) The input is incorrect; compile_command() raised an exception (SyntaxError or OverflowError).
2) The input is incomplete, and more input is required; compile_command() returned None. Nothing happens.
3) The input is complete; compile_command() returned a code object. The code is executed by calling self.runcode() (which also handles run-time exceptions, except for SystemExit).
The return value is:
- True in case 2
- False in the other cases, unless an exception is raised, where
None is returned instead. This can be used by external callers to know whether to continue feeding input or not.
The return value can be used to decide whether to use sys.ps1 or sys.ps2 to prompt the next line.
Put a formatted version of the traceback into value and reraise.
When exceptions have to be sent over the network, the traceback needs to be put into the value of the exception in a nicely formatted way. The method takes the type, value and tb of an exception and puts a string representation of the tb into the value of the exception and reraises it.
Currently this method uses the ultraTb formatter from IPython trunk. Eventually it should simply use the traceback formatters in core that are loaded into self.tracback_trap.formatters.
Calculate and return a string with the prompt to display.
that a proper continuation prompt can be computed.
Gets the ith message in the message_cache.
This is implemented here for compatibility with the old ipython1 shell I am not sure we need this though. I even seem to remember that we were going to get rid of it.
Call a magic function by name.
ipmagic(‘name -opt foo bar’) is equivalent to typing at the ipython prompt:
In: %name -opt foo bar
To call a magic without arguments, simply use ipmagic(‘name’).
This provides a proper Python function to call IPython’s magics in any valid Python code you can type at the interpreter, including loops and compound statements. It is added by IPython to the Python builtin namespace upon initialization.
arg_string : str
something : object
Execute a command in a system shell while expanding variables in the current namespace.
|Parameters :||command : str|
Get an item out of the namespace by key.
key : str
value : object
TypeError if the key is not a string. :
NameError if the object doesn’t exist. :
Put value into the namespace with name key.
|Parameters :||**kwds :|
Reset the interpreter.
Currently this only resets the users variables in the namespace. In the future we might want to also reset the other stateful things like that the Interpreter has, like In, Out, etc.
Set all of the output, display, and traceback traps.
Return a message object.
This method prepares and returns a message dictionary. This dict contains the various fields that are used to transfer information about execution, results, tracebacks, etc, to clients (either in or out of process ones). Because of the need to work with possibly out of process clients, this dict MUST contain strictly pickle-safe values.
Add things to the namespace.
Split multiple lines of code into discrete commands that can be executed singly.
python : str
commands : list of str
Unset all of the output, display, and traceback traps.
Expand $variables in the current namespace using Itpl.
|Parameters :||template : str|