Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.07; 'python': 0.08; '*function*': 0.09; '>>>>': 0.09; "module's": 0.09; 'subject:Function': 0.09; 'wrote:': 0.15; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'docstring': 0.16; 'linux2': 0.16; 'richardson': 0.16; 'subject:variable': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'def': 0.16; 'cheers,': 0.19; 'slightly': 0.19; 'cc:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'module,': 0.23; 'code': 0.24; 'there.': 0.25; 'message-id:@mail.gmail.com': 0.28; 'environment': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; '-0400': 0.30; 'carl': 0.30; 'sun,': 0.30; 'print': 0.32; 'chris': 0.32; 'does': 0.32; '...': 0.34; 'quite': 0.34; "can't": 0.34; 'test': 0.34; 'none': 0.35; 'do?': 0.35; "isn't": 0.35; 'question': 0.35; 'received:google.com': 0.38; 'subject:: ': 0.38; 'received:74.125': 0.40; 'give': 0.60; 'relevant': 0.69; 'yours': 0.84; '2.7.1': 0.84; '2011:': 0.84; 'sender:addr:chris': 0.84; 'subject:local': 0.84; 'to:addr:aim.com': 0.84; 'url:rebertia': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=dHzZg9zhSMt29DB9dqF5wLzs41uGhK2c3SmdOAZTjKw=; b=MEk8TcZIyvlKiQUQhQ/EkRTcrlhrMKsX1g0wgivUZTGF2Z0E4wq9RpxAlaoOpYlJWC LSVDZI8QJM/x/aXEhAuzzaRvyKZ0O8hUMm+0PM/h9fA4bfr139CuVl/JHjTbjPw09JQz C/KAaw6ua0Pzrg/jNzaippX1Mvg772d83qEyw= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: <1310339164-sup-5162@dalek> References: <1310339164-sup-5162@dalek> Date: Sun, 10 Jul 2011 17:16:23 -0700 X-Google-Sender-Auth: obVC2f-3_JK7fY1O0bnbyUvU_yE Subject: Re: Function docstring as a local variable From: Chris Rebert To: Corey Richardson Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310343387 news.xs4all.nl 21815 [2001:888:2000:d::a6]:54090 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9207 On Sun, Jul 10, 2011 at 4:06 PM, Corey Richardson wrote: > Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011: >> print __doc__ >> > > Python 2.7.1 (r271:86832, Jul =C2=A08 2011, 22:48:46) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> def foo(): > ... =C2=A0 =C2=A0 "Docstring" > ... =C2=A0 =C2=A0 print __doc__ > ... >>>> foo() > None >>>> > > > What does yours do? The question Carl's code was in answer to was, slightly paraphrased: "Is it possible to get a *module*'s docstring from within the module itself?" The question had nothing to do with *function* docstrings. The interactive interpreter environment also isn't quite a true module, so you can't give it a docstring or really test the relevant feature there. Try this instead: $ cat test.py """I am the docstring of the `test` module!""" print("This module's docstring is:", __doc__) $ python test.py This module's docstring is: I am the docstring of the `test` module! $ Cheers, Chris -- http://rebertia.com