Path: csiph.com!usenet.pasdenom.info!news.etla.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'received:134': 0.05; 'clause': 0.09; 'parsed': 0.09; 'worse': 0.09; '10:45': 0.16; 'clause.': 0.16; 'clauses': 0.16; 'construct.': 0.16; 'for,': 0.16; 'indent': 0.16; 'programmer,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'seems': 0.21; '>>>': 0.22; 'header:User-Agent:1': 0.23; "shouldn't": 0.24; 'together.': 0.24; "haven't": 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; 'lines': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:end': 0.31; 'done.': 0.35; 'but': 0.35; "didn't": 0.36; 'should': 0.36; 'saves': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'that,': 0.38; 'anything': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'chain': 0.60; 'become': 0.64; 'risk': 0.72; 'obvious': 0.74; 'ambiguous': 0.84; 'cost,': 0.84; 'nonsense.': 0.84; 'pardon': 0.84; 'hand,': 0.93 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EAFFuJFKGuA9G/2dsb2JhbABawgCDAoE5gxgBAQUyAUURCxgJFg8JAwIBAgFFEwgCh36wRYhvkAYWhAcDl3WGGItOgyI Date: Mon, 02 Sep 2013 12:58:23 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 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> <522446ae$0$2743$c3e8da3$76491128@news.astraweb.com> <52245E2F.4020909@rece.vub.ac.be> <52246BAD.9050403@gmail.com> In-Reply-To: <52246BAD.9050403@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378119505 news.xs4all.nl 16010 [2001:888:2000:d::a6]:51806 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53473 Op 02-09-13 12:42, Fábio Santos schreef: > On 09/02/2013 10:45 AM, Antoon Pardon wrote: >> Op 02-09-13 10:05, Steven D'Aprano schreef: >>> It doesn't keep a whole chain of >>> if clauses together. It doesn't let you do anything that you haven't >>> already done. It just saves an indent and a newline. The cost, on the >>> other hand, includes the risk that people will try to do this: >>> >>> for item in seq: if cond: >>> do_this() >>> do_that() >>> else: >>> do_something else() >>> >>> which is clearly nonsense. Worse is this: >>> >>> for item in seq: if cond: >>> do_this() >>> do_that() >>> else: >>> do_something else() >>> >>> which is still nonsense but won't raise SyntaxError. >> Why shouldn't this raise a SyntaxError? >> > Because it would be parsed as a valid for .. else construct. Either that > or become ambiguous to the programmer, who would not be sure whether he > was writing an else clause for the `if`, or for the `for`. I didn't thought about that, but in that case why should we automatically think of it as nonsense? I also don't see how this would be that ambigous. The else lines up with the for, so it seems rather obvious for which he was writing an else clause. -- Antoon Pardon