[IPython-user] Recording sessions

Fernando Perez fperez.net at gmail.com
Mon May 29 20:49:06 CDT 2006

On 5/27/06, Ken Schutte <kschutte at csail.mit.edu> wrote:
> Fernando Perez wrote:
> > No, something like that doesn't really currently exist.  Short of
> > building a true 'notebook' interface (for which we do have a proof of
> > concept prototype, but nothing production-ready), you might be able to
> > hack together an expect-based system which feeds a file, one line at a
> > time, to a running ipython.
> expect was another tool I didn't know about... I found the Pexpect
> python module (pexpect.sourceforge.net) and that made it easy to throw
> something together that does the trick,
> import pexpect, sys
> c = pexpect.spawn('/usr/bin/env ipython -colors NoColor')
> c.expect('In \[\d+\]: ')
> sys.stdout.write(c.after)
> f=open('my_cmds.py')
> for cmd in f:
>      c.sendline(cmd[0:-1])
>      c.expect('In \[\d+\]: ')
>      sys.stdout.write(c.before)
>      sys.stdout.write(c.after)

Well, you probably qualify for the record in shortest time between
question on ipython-user and contribution to the core code :)


in particular:


( as you can see, I enhanced your original a little bit :)




More information about the IPython-user mailing list