Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail From: "D'Arcy J.M. Cain" Newsgroups: comp.lang.python Subject: Re: Procedures and functions [was Re: Why not allow empty code blocks?] Date: Sun, 31 Jul 2016 00:01:33 -0400 Organization: Vex.Net Lines: 27 Message-ID: References: <579B1ABB.1070500@rece.vub.ac.be> <579c2095$0$22142$c3e8da3$5496439d@news.astraweb.com> <579cbded$0$1605$c3e8da3$5496439d@news.astraweb.com> <758a1961-00bc-4b1c-834b-a7deca94d029@googlegroups.com> <579d7141$0$1606$c3e8da3$5496439d@news.astraweb.com> <20160731000133.276c46f0@imp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de mPXAZAoltwqpJJp977ffJQLBrR40WXIOUR/jNCZrSuXA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'run-time': 0.05; 'compile-time': 0.07; 'subject:code': 0.07; 'cc:addr:python- list': 0.09; 'beginners': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; 'syntax': 0.13; 'subject: \n ': 0.15; '2016': 0.16; 'bugs.': 0.16; 'mylist': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:allow': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; 'attribute': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '"",': 0.22; 'latter': 0.22; 'cc:no real name:2**0': 0.22; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'subject: [': 0.29; 'source': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'traceback': 0.33; 'file': 0.34; 'instead': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'jul': 0.72; 'obvious': 0.76; 'received:98.158': 0.84; '+1000': 0.91; 'mistake': 0.91; 'write:': 0.91; 'mystery': 0.95 In-Reply-To: <579d7141$0$1606$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20160731000133.276c46f0@imp> X-Mailman-Original-References: <579B1ABB.1070500@rece.vub.ac.be> <579c2095$0$22142$c3e8da3$5496439d@news.astraweb.com> <579cbded$0$1605$c3e8da3$5496439d@news.astraweb.com> <758a1961-00bc-4b1c-834b-a7deca94d029@googlegroups.com> <579d7141$0$1606$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:112117 On Sun, 31 Jul 2016 13:32:16 +1000 Steven D'Aprano wrote: > Many beginners make the mistake of writing: > > mylist = mylist.sort() > > or try to write: > > mylist.sort().reverse() > > If we had procedures, that would be an obvious error (possibly even a > compile-time syntax error) instead of a perplexing source of mystery > bugs. While neither is a syntax error, the latter is definitely a run-time error: >>> mylist.sort().reverse() Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'reverse' -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:darcy@Vex.Net VoIP: sip:darcy@Vex.Net