Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Why not allow empty code blocks? Date: Fri, 29 Jul 2016 06:11:52 +1000 Lines: 37 Message-ID: References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de stocvjTYALzwysjXS1VmSwYgBseOVHSvQQ6j9uX37dRQ== 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; 'that?': 0.05; 'subject:code': 0.07; 'cc:addr:python-list': 0.09; 'block.': 0.09; 'normally,': 0.09; 'subject:Why': 0.09; 'yeah,': 0.09; 'subject:not': 0.11; '2016': 0.16; '23,': 0.16; '9:13': 0.16; 'dummy': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'statement.': 0.16; 'statements,': 0.16; 'stuff,': 0.16; 'subject:allow': 0.16; 'wrote:': 0.16; 'try:': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'saying': 0.22; 'keyerror:': 0.22; 'pass': 0.22; 'am,': 0.23; 'sat,': 0.23; 'thus': 0.24; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'block,': 0.29; 'optional.': 0.29; "i'm": 0.30; 'code': 0.30; 'possibly': 0.32; 'statement': 0.32; 'common': 0.33; 'except': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'requirement': 0.37; 'stuff': 0.38; 'rather': 0.39; 'where': 0.40; 'here.': 0.62; 'needing': 0.63; 'statement,': 0.66; 'situation': 0.67; 'jul': 0.72; 'actually,': 0.84; 'chrisa': 0.84; 'urge': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=KRAPagnyzMpDKcx28q+RMlL/20Jf8+ZjSIzAoNh05g0=; b=en2UGo2jfgQEDaTIPmq25lI5XGSLTLkeBGgQKZtgcS30MlOrEB3WXVU9wlbXNHRCr/ R8l0B3BKHvo1biSu8ZByS7TqktIasp22YiUYX7+FRuK4EhIg9dWnuM2E04eQLsroDCZ1 d/cq+Uchi9NB6hkOLGxvMF4dexpSwyhA45KRSRs9uQQq0vSStnjXx2tq9YK+V699iKzP kISvT+BaPbm44BLbfCnsEtO6r1nShgDI4e6Q9TxA6982Q8wb9ET4Nyk1z5aW+BCvFS9Z Vcl07wkFY7CLCkSML/FguHVzF+glXeUvH3LcuthVi+aqxZ+NrVAaOIKc67TNa63bDEi+ ma1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=KRAPagnyzMpDKcx28q+RMlL/20Jf8+ZjSIzAoNh05g0=; b=OVJM+psCKfn8y8EFGGZp6Qd6jAlWYflkBjked1M3o6op8nGTjYgjQqzQfps6WwRjBY /6jHfKMMvBxXIB+qjK3ZqWZRZI96Gil52WQs5QY6uLvYqZlAr9t0MWFnMBwc+x+2b8rk M9dlS/pg2FuiTxJGR8u5zVQAWMCoPmONeWe5aplRZ59lFNNFZq1OQ1lr1MXPJCaNMcnC JYR8yLqZHVAZupx7JtEZ4+VZVTf7yZma0ABuT9d0+JRLFcN/TEhEig6CsVJ/+hYWTYQP jPPcYSqyMxoj2duqV4186cVlLnCyJxifyBbWZ881cK6RPHyC6cFpVdSREm9MU/uPDBBV M8wA== X-Gm-Message-State: AEkooutpMnd7BQP3wp1Og5tght7ega07t42xHT9Phmqb6v+momySP/FVWtNxcVKO8WY6PVB9hESFl9cMW+kc4Q== X-Received: by 10.194.221.232 with SMTP id qh8mr34987616wjc.117.1469736713992; Thu, 28 Jul 2016 13:11:53 -0700 (PDT) In-Reply-To: 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: X-Mailman-Original-References: <5792cd34$0$1587$c3e8da3$5496439d@news.astraweb.com> <87vazwppxx.fsf@elektro.pacujo.net> Xref: csiph.com comp.lang.python:111993 On Fri, Jul 29, 2016 at 6:01 AM, Rob Gaddi wrote: > Chris Angelico wrote: > >> On Sat, Jul 23, 2016 at 9:13 PM, Marko Rauhamaa wrote: >>>> One less thing to be programmed, one less thing for the user to >>>> remember. Just require pass any time you have an empty block, rather >>>> than try to remember where it is required and were it is optional. >>> >>> 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. >> >> How often do you actually need empty statements, adding stuff, >> removing stuff, like that? Possibly there's a code smell here. >> >> ChrisA > > Yeah, all the time. > > try: > return self.cache[key] > except KeyError: > pass > > lots... of... code... > self.cache[key] = newval > return newval It's common to *use* empty statements. What I'm saying is, do you often have the situation Marko raises, where you need an empty statement to which you add stuff and remove stuff, thus needing the insertion/removal of 'pass'? Normally, you use 'pass' in a situation where it's always going to remain an empty block. ChrisA