Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9193

Re: Function docstring as a local variable

Date 2011-07-10 14:50 -0800
From Tim Johnson <tim@johnsons-web.com>
Subject Re: Function docstring as a local variable
References <20110710174121.GB12935@johnsons-web.com> <4E19E5A5.5020905@gmail.com> <mailman.844.1310321477.1164.python-list@python.org> <c5669e17-290e-455c-975d-5f659129e6b4@d7g2000vbv.googlegroups.com> <1310336009.20776.2150240761@webmail.messagingengine.com>
Organization AkWebsoft
Newsgroups comp.lang.python
Message-ID <mailman.857.1310338213.1164.python-list@python.org> (permalink)

Show all headers | View raw


* python@bdurham.com <python@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Function docstring as a local variable Chris Angelico <rosuav@gmail.com> - 2011-07-11 04:11 +1000
  Re: Function docstring as a local variable Richard Thomas <chardster@gmail.com> - 2011-07-10 14:16 -0700
    Re: Function docstring as a local variable python@bdurham.com - 2011-07-10 18:13 -0400
      Re: Function docstring as a local variable Roy Smith <roy@panix.com> - 2011-07-10 18:41 -0400
    Re: Function docstring as a local variable Tim Johnson <tim@johnsons-web.com> - 2011-07-10 14:50 -0800
    Re: Function docstring as a local variable Tim Chase <python.list@tim.thechases.com> - 2011-07-10 18:14 -0500

csiph-web