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


Groups > comp.lang.python > #9186

Re: Function docstring as a local variable

From python@bdurham.com
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>
Subject Re: Function docstring as a local variable
Date 2011-07-10 18:13 -0400
Newsgroups comp.lang.python
Message-ID <mailman.852.1310336017.1164.python-list@python.org> (permalink)

Show all headers | View raw


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()

Outputs:

This is my doc string

Malcolm

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