Save session in python interactive console

Fernando Pérez fperez528 at yahoo.com
Mon Sep 9 17:54:47 EDT 2002


newgene wrote:

> Hi, group,
>     After I was working at python interactive console(activepython
> v2.2 at Win2000 platform), I am wondering if possible to save the
> current session, so that I can load it again and continue the work
> next time. Just like R or Matlab, etc. Although python is a
> programming language, one of the best features I like is its
> interactive console. By writting my own module, I can make it as my
> personal working console. If saving session is possible, it will be
> much more convinient.
>     The pickle module provided by python can save any object,but how
> can I save all objects in current session?

This problem is non-trivial and a plain pickle solution will fail. You may 
want to try ipython, which is a better interactive command-line environment 
than the default one and has _limited_ save/restore abilities. I tried using 
pickle but failed, so until I have time to dig deeper into the problem I 
implemented a log save/replay option which while admittedly imperfect, in 
many cases is a reasonable solution.

You'll find ipython at: http://www-hep.colorado.edu/~fperez/ipython/

Cheers,

f.

ps. Some of ipython's nicest features only work in a proper terminal which 
Windows lacks, so you'll need either a Unix environment or the Cygwin system 
under Windows. However the basics stuff is all there under windows.



More information about the Python-list mailing list