Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.066 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.02; 'else:': 0.03; 'elif': 0.05; 'level,': 0.07; 'python': 0.11; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'indent': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'option:': 0.16; 'readability': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'sequence:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'aug': 0.22; 'header:User-Agent:1': 0.23; 'header :In-Reply-To:1': 0.27; '+0100,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:end': 0.31; 'option': 0.32; 'fri,': 0.33; 'except': 0.35; 'problem.': 0.35; 'received:84': 0.35; 'really': 0.36; 'combination': 0.36; 'sequence': 0.36; 'level': 0.37; 'saves': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'either': 0.39; 'situation': 0.65; 'between': 0.67; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'forced': 0.84; 'fourth': 0.84; 'gains': 0.84; 'pardon': 0.84; 'reply-to:addr:python.org': 0.84; 'absolutely': 0.87; 'mistake': 0.91; 'write:': 0.91; 'hand,': 0.93; '2013': 0.98 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=ZMDuxxLb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=i8OrkJrcdewA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=5soDUyuNH4oA:10 a=LmIGk39enKkzjC6zS_MA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett:2500 Date: Mon, 02 Sep 2013 00:30:35 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: semicolon at end of python's statements References: <1377735506.18906.15.camel@debian> <1FETt.52607$Mw4.14965@fx15.am4> <7wob8gywds.fsf@benfinney.id.au> <52213435$0$6599$c3e8da3$5496439d@news.astraweb.com> <52239C57.9090506@rece.vub.ac.be> In-Reply-To: <52239C57.9090506@rece.vub.ac.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 68 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378078223 news.xs4all.nl 15905 [2001:888:2000:d::a6]:54976 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53439 On 01/09/2013 20:58, Antoon Pardon wrote: > Op 31-08-13 02:09, Steven D'Aprano schreef: >> On Fri, 30 Aug 2013 11:32:17 +0100, Fábio Santos wrote: >> > >> >> We really are spoiled for choice here. We can write any of these: >> >> # Option 1 >> for spam in sequence: >> if predicate(spam): >> process(spam) >> > >> >> Adding a fourth option: >> >> for spam in sequence if predicate(spam): >> process(spam) >> >> saves absolutely nothing except a line and an indent level, neither of >> which are in short supply, and gains nothing in readability over Option 1. > > So what is the big difference between this situation and the following: > > | else: > | if condition: > | whatever > > which in python we can write: > > | elif condition: > | whatever > > > So either is seems this was a design mistake or a line and an indent > level can be important enough to allow a combination of controls. > 'elif' is for cascading ifs: if ...: ... elif ...: ... elif ...: ... elif ...: ... else: ... Without 'elif' you would be forced to write: if ...: ... else: if ...: ... else: if ...: ... else: if ...: ... else: ... On the other hand, for...if is much less of a problem.