Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: Useless expressions Date: Tue, 29 Mar 2016 18:35:34 +1100 Lines: 43 Message-ID: References: <56f42d9f$0$1618$c3e8da3$5496439d@news.astraweb.com> <56f55e2e$0$1619$c3e8da3$5496439d@news.astraweb.com> <87wpoq1omm.fsf@elektro.pacujo.net> <56f5f81d$0$1585$c3e8da3$5496439d@news.astraweb.com> <87io0a6j1w.fsf@nightsong.com> <56f67ee3$0$1583$c3e8da3$5496439d@news.astraweb.com> <87poug5t0c.fsf@nightsong.com> <56f887c1$0$1598$c3e8da3$5496439d@news.astraweb.com> <56fa2ae1$0$1502$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de rAB32M0nNFmSM3Xl39pt1g7gLT3chkvOSd3S/uwg7R8A== Cancel-Lock: sha1:+JXzINGdbrEI6jhSSc863Xvk5Xw= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'practice,': 0.07; 'attribute.': 0.09; 'definition,': 0.09; 'literal': 0.09; "object's": 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'syntax': 0.13; '"python': 0.16; '(there': 0.16; '2016': 0.16; 'agree.': 0.16; 'docstring': 0.16; 'evaluates': 0.16; 'expression)': 0.16; 'expression.': 0.16; 'expressions.': 0.16; 'greatness': 0.16; 'literal,': 0.16; 'measured': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:expressions': 0.16; 'wrote:': 0.16; 'string': 0.17; 'module,': 0.18; '(not': 0.20; '(the': 0.22; 'class,': 0.22; 'this:': 0.23; 'header:User-Agent:1': 0.26; 'appear': 0.26; 'header:X-Complaints-To:1': 0.26; 'object,': 0.27; 'yesterday': 0.27; 'docstrings': 0.29; 'documenting': 0.29; 'url:wikipedia': 0.29; 'url:wiki': 0.30; 'code': 0.30; 'says': 0.32; 'language.': 0.32; 'statement': 0.32; 'common': 0.33; "d'aprano": 0.33; 'hopefully': 0.33; 'raising': 0.33; 'steven': 0.33; 'definition': 0.34; 'but': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'means': 0.39; 'url:en': 0.39; "didn't": 0.39; 'to:addr:python.org': 0.40; 'wall': 0.63; 'march': 0.64; "'class'": 0.84; "'def'": 0.84; '_o__)': 0.84; 'article,': 0.84; 'function)': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105957 Steven D'Aprano writes: > On Monday 28 March 2016 23:18, BartC wrote: > > > (There are also docstrings, but until yesterday I didn't even know > > they were also expressions. Wikipedia says this: > > > > "Python docstrings appear as a string literal (not an expression) as > > the first statement following the definition of functions..." > > > > so their status is a little unclear. Thanks for raising this, Bart. > I think what Wikipedia means is that you cannot use an expression that > evaluates to a string as a docstring I agree. I have edited that section of the article, hopefully it is now clearer: Python The common practice, of documenting a code object at the head of its definition, is captured by the addition of docstring syntax in the Python language. The docstring for a Python code object (a module, class, or function) is the first statement of that code object, immediately following the definition (the 'def' or 'class' statement). The statement must be a bare string literal, not any other kind of expression. The docstring for the code object is available on that code object's '__doc__' attribute. […] -- \ “True greatness is measured by how much freedom you give to | `\ others, not by how much you can coerce others to do what you | _o__) want.” —Larry Wall | Ben Finney