recall function definition from shell

Patrick Maupin pmaupin at gmail.com
Tue May 18 14:32:40 EDT 2010


On May 18, 12:31 pm, superpollo <ute... at esempio.net> wrote:
>  >>> def myfun():
> ...     return "WOW"
> ...
>  >>> myfun()
> 'WOW'
>  >>>
>
> now, i would like to "list" the funcion definition, something like this:
>
>  >>> myfun.somethinglikethis()
> def myfun():
>      return "WOW"
>  >>>
>
> is there something like this around?
>
> bye

Sure, just give it a docstring and then you can call help on it:

>>> def myfun():
...     ''' myfun returns "WOW" when called.
...         This is just a Python __doc__ string
...     '''
...     return "WOW"
...
>>> help(myfun)

Regards,
Pat



More information about the Python-list mailing list