Retracing your steps in an interactive python env

Mensanator mensanator at aol.com
Tue Sep 15 01:21:18 CEST 2009


On Sep 14, 2:52 pm, Jack Norton <j... at 0x6a.com> wrote:
> Hello all,
>
> I am playing around in a python shell (IPython on win32 right now
> actually).  I am writing some code on the fly to interface to a rotary
> encoder (not important in this scope).
>
> 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?)

I usually have my buffer default to 8000x132.

> 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.
> Something like this (remember I am using IPython interactive interpreter
> session):
> In [0]: def func(input):
> .........:>>>print "im in this function!" + str(input)
> .........:>>>print "doing some stuff"
> .........:>>>sleep(10)
>
> Then later on while still in this interactive shell session I could do
> something like:
> In [1]: what_is_in(func)
> "The def for func(input) is:"
> print "im in this function!" + str(input)
> print "doing some stuff"
> sleep(10)
>
> and therefore be able to recount what I just did.
>
> Cheers,
>
> Jack




More information about the Python-list mailing list