Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.08; 'foo': 0.09; 'question:': 0.09; 'received:64.4': 0.09; 'subject:Function': 0.09; '"""this': 0.16; 'docstring': 0.16; 'module:': 0.16; 'subject:variable': 0.16; 'templating': 0.16; 'test()': 0.16; 'test():': 0.16; '>>>': 0.16; 'def': 0.16; 'header :In-Reply-To:1': 0.22; 'function': 0.26; "i'm": 0.27; 'import': 0.29; 'generic': 0.29; 'module': 0.30; 'imported': 0.30; 'thanks': 0.31; 'print': 0.32; 'to:addr:python-list': 0.34; 'header:User- Agent:1': 0.34; 'doc': 0.35; 'itself,': 0.35; 'charset:us-ascii': 0.36; 'but': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'subject:local': 0.84; 'technique': 0.93 Date: Sun, 10 Jul 2011 14:50:18 -0800 From: Tim Johnson To: python-list@python.org Subject: Re: Function docstring as a local variable References: <20110710174121.GB12935@johnsons-web.com> <4E19E5A5.5020905@gmail.com> <1310336009.20776.2150240761@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1310336009.20776.2150240761@webmail.messagingengine.com> Organization: AkWebsoft User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310338213 news.xs4all.nl 21791 [2001:888:2000:d::a6]:43512 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9193 * 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