[IPython-dev] Embedding IPython in IEP

Almar Klein a.klein at science-applied.nl
Mon Jan 20 09:14:03 EST 2014


Hi all,

I am currently working on embedding IPython in IEP (Interactive Editor for
Python - http://iep-project.org), and I am interested in getting some
feedback.

The approach that I am taking right now is to hook into IPython at a rather
low level and integrate it with relatively small changes to the existing
code-base for the IEP kernel. It basically comes down to this:

 from IPython.core.interactiveshell import InteractiveShell
self._ipython = InteractiveShell(user_module=__main__)
# set a few hooks ...
...
# When user is sending a line to execute ...
if self._ipython:

self._ipython.run_cell(source, True)

else:

self._run_cell_natively(source)


Apart from this I use custom prompts at sys.ps1 and sys ps2 to simulate the
IPython prompts, plus a handfull of small tweaks to make things work as
expected.


The kernel runs the event loop as usual and arranges for GUI integration.


So far things are looking good and everything seems to work as expected. I
was mostly wondering whether this approach has any limitations that I
overlooked, like some specific IPython feature that is not available with
this approach. Also, I would be happy to learn any specific things that I
should take into account.


Thanks in advance,

Almar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140120/980a4e47/attachment.html>


More information about the IPython-dev mailing list