On Sep 14, 2:52 pm, Jack Norton <j...@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?) 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
You could put the entire def in a multi line doc string...? >>> print func.__doc__ Considering you created a doc string. -- http://mail.python.org/mailman/listinfo/python-list