[IPython-dev] headless IPython

Robert Kern robert.kern at gmail.com
Thu Apr 19 12:40:12 EDT 2007

Andrew Dalke wrote:
> I've got an idea I would like to work on but I'm having
> a hard time getting started.
> What I want is an interactive Python session through a web interface.
> I'm doing this for chemistry so my example is:
>    >>> mol = load_molecule("input_filename")
>    >>> repr(mol)
>    <Molecule object at 0x827f0>)
>    >>> mol
>        .======.
>       /        \
>      /          \
>      \\         //
>       \\       //
>        ``-----''
>         benzene
> That is, molecule objects are displayed using one of several
> ways to depict the structure (image, java applet, or plugin,
> depending on user configuration).
> This will build up into a larger system, with more data types.
> For example, ideally I would also like if 'p' were a matplotlib
> plot then typing 'p'
>     >>> p
> should inline the plot in the browser display.  Very much like
> Mathematica and similar projects.

It is currently difficult to do something like this in IPython. The code is just
too monolithic. I've been desultorily working on an architecture cleanup of
IPython that I hope to work out with Fernando and co. at the sprint on the 28th.
I had exactly what you describe in mind when I designing it. Basically, I wanted
pluggability for the the various execution hooks (sys.displayhook in this case,
but also sys.excepthook and sys.stdout/stderr) in order to trap the information
where it is being executed (possibly a remote interpreter), format it in
potentially multiple ways, and then pass that data back. The core "E" component
in "REPL" could then be associated with different "R" and "P" front ends

You can take a look at the current stage of the code in my Mercurial repository


Click "manifest" to browse the repository, "bz2", "zip" or "gz" to get a
snapshot, or if you have Mercurial:

  hg clone http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/ipwx/

Read the README.txt.

It uses Enthought's Traits, but it wouldn't be impossible to remove that for the
non-UI bits. The code is really a prototype, so there is much to clean up. The
wxPython UI stuff should be separated out, of course. Also, very few of
IPython's special features have been ported, so it's not even really IPython, yet.

This is, of course, one side project among many for me, but if anyone would like
to help move this forward, I can certainly put it higher on my stack.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the IPython-dev mailing list