Retracing your steps in an interactive python env

Bernhard Voigt bernhard.voigt at gmail.com
Tue Sep 15 06:35:22 EDT 2009


On Sep 14, 9:52 pm, Jack Norton <j... at 0x6a.com> wrote:

> Anyway, I have created a function using def, and well, I like the way it
> is working, however...  I have already filled the command line history
> buffer (the com.exe buffer?) so _what_ I actually filled this def with
> is lost.  Now, it isn't that complicated, and I can easily re-write the
> function off the top of my head, however it would be really nice to be
> able to _ask_ python what makes up a def.

IPython has it's own history. Accessible using the %hist magic
command, the default is 1000 lines but can be changed in the ipythonrc
file.
There are many other magic commands which are very useful for
interactive development. For example there's a %log command that
enables logging of your session in a file. Another example is %save to
store parts of your history into a file and %edit to launch an
external editor to edit a bunch of commands from the history or enter
longer blocks of code. Take a look at the documentation of the magic
commands by entering %magic.

Bernhard



More information about the Python-list mailing list