Path: csiph.com!feeder.erje.net!1.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: Why not allow empty code blocks? Date: Sat, 23 Jul 2016 08:29:47 -0400 Organization: Vex.Net Lines: 38 Message-ID: References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> <20160723082947.7cae8bd1@imp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de vQLURWdgkicQmvpd7G7pvQaO3S3yTBZ0/HUmGP+BmCjw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:code': 0.07; 'cc:addr:python-list': 0.09; 'block.': 0.09; 'forcing': 0.09; 'loop.': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; '+0300': 0.16; '2016': 0.16; 'aesthetic': 0.16; 'dummy': 0.16; 'mistake.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sequence:': 0.16; 'statement.': 0.16; 'subject:allow': 0.16; 'wrote:': 0.16; 'obviously': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'meant': 0.22; 'explicit': 0.22; 'pass': 0.22; 'cc:no real name:2**0': 0.22; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'wonder': 0.27; 'looks': 0.29; 'loop,': 0.29; 'once,': 0.29; 'print': 0.30; 'guess': 0.31; 'knows': 0.32; 'statement': 0.32; 'add': 0.34; 'comment': 0.35; 'there': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'requirement': 0.37; 'charset:us-ascii': 0.37; 'end': 0.39; 'takes': 0.39; 'hope': 0.61; 'statement,': 0.66; 'jul': 0.72; 'actually,': 0.84; 'enforced': 0.84; 'received:98.158': 0.84; 'alone.': 0.91; 'urge': 0.91 In-Reply-To: <87vazwppxx.fsf@elektro.pacujo.net> 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: <20160723082947.7cae8bd1@imp> X-Mailman-Original-References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:111786 On Sat, 23 Jul 2016 14:13:46 +0300 Marko Rauhamaa wrote: > > for x in sequence: > > print('loop') > > > > Is that meant to print 'loop' each time around the loop, or just > > once, at the end of the loop? > > I don't see an ambiguity: obviously the print call takes place after > finishing the loop. It's ambiguous to the reader what was actually meant. Forcing a "pass" there shows the reader that the empty block was not a mistake. Explicit is better than implicit. > I wonder if there is any true case of ambiguity. I guess this is all > about an enforced aesthetic principle: GvR doesn't like the looks of > an empty block. I don't think that he would be alone. > Actually, the requirement of a dummy statement is a slight annoyance > for the programmer. After deleting a statement, you must see if you > have to put in a pass statement. And after adding a statement, you > may feel the urge to remove the redundant pass statement. If you allow empty blocks and you use it I hope that you would add a comment so that the reader knows that you meant it. for x in sequence: # this is an empty block Is that better than "pass"? -- D'Arcy J.M. Cain System Administrator, Vex.Net http://www.Vex.Net/ IM:darcy@Vex.Net VoIP: sip:darcy@Vex.Net