Retracing your steps in an interactive python env
jack at 0x6a.com
Mon Sep 14 21:52:34 CEST 2009
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?) 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
In : def func(input):
.........:>>>print "im in this function!" + str(input)
.........:>>>print "doing some stuff"
Then later on while still in this interactive shell session I could do
In : what_is_in(func)
"The def for func(input) is:"
print "im in this function!" + str(input)
print "doing some stuff"
and therefore be able to recount what I just did.
More information about the Python-list