I have a bug in my program :(
The problem is that:
Very interesting question! Fortunately IPython has the right magic for you. It's called
%logstart (please follow the link for the full documentation).
To start using it and save the input and output of all your commands, just type in an IPython console
In: %logstart -o
and that will record your session from that moment on into a file called
ipython_log.py placed in your current directory.
%logstart is very flexible, so you can select a different file to save to, and also how you save your session (either pure Python or as IPython commands).