Function docstring as a local variable
Tim Johnson
tim at johnsons-web.com
Sun Jul 10 18:50:18 EDT 2011
* python at bdurham.com <python at bdurham.com> [110710 14:17]:
> I'm not sure how a function can get a generic handle to itself, but if
> you're willing to hardcode the function name, then this technique works:
>
> def test():
> """This is my doc string"""
> print test.__doc__
>
> test()
Works for me. Works for the application I'm after. thanks
Here's a related question:
I can get the docstring for an imported module:
>>> import tmpl as foo
>>> print(foo.__doc__)
Python templating features
Author - tim at akwebsoft dot com
## Is it possible to get the module docstring
## from the module itself?
Thanks again
--
Tim
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
More information about the Python-list
mailing list