Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Assignment Versus Equality Date: Tue, 28 Jun 2016 20:34:59 +1000 Lines: 29 Message-ID: References: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <576fd6e0$0$1617$c3e8da3$5496439d@news.astraweb.com> <2588c5b2-4b6f-cfbb-f91e-4db03aa50318@icloud.com> <8fbe89a6-c273-0fc9-820b-6ac629e6e769@gmail.com> <02e2d3f4-0198-4cdf-a493-45a248c03aea@googlegroups.com> <577129e0$0$1596$c3e8da3$5496439d@news.astraweb.com> <5771cd54$0$1589$c3e8da3$5496439d@news.astraweb.com> <4805e31e-040d-4caf-a79e-af56f93f6daf@googlegroups.com> <57720e58$0$1530$c3e8da3$5496439d@news.astraweb.com> <3bd25897-8ecb-4a27-ab22-220677551f41@googlegroups.com> <01ed522b-71d6-4535-8d49-b0e32c33ee3a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de j8KWeqp/Ob/xGZvnHzhqywoVDBSy+z3I2yu8QroUp5Xw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'cleanup': 0.07; 'cc:addr :python-list': 0.09; '(error)': 0.16; '2016': 0.16; '488': 0.16; 'begging': 0.16; 'different?': 0.16; 'doesn\xe2\x80\x99t': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'targeting': 0.16; 'trap.': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'lawrence': 0.22; 'scale.': 0.22; '(you': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'example': 0.26; 'chris': 0.26; 'error': 0.27; 'handling': 0.27; 'separate': 0.27; 'switch': 0.27; 'message-id:@mail.gmail.com': 0.27; 'actual': 0.28; 'loop,': 0.29; 'e.g.': 0.30; 'probably': 0.31; 'instances': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'label': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'lines': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'mean': 0.38; 'why': 0.39; 'rather': 0.39; 'future': 0.60; 'your': 0.60; 'lose': 0.63; 'fall': 0.66; "they're": 0.66; 'chrisa': 0.84; 'murdered': 0.84; 'absolutely': 0.88; 'to:none': 0.91; 'device,': 0.91; 'dozen': 0.91; 'not:': 0.93; 'insane': 0.95 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:cc :content-transfer-encoding; bh=MIPbFjVY++6vKQbewaqtkKG97IWh1StdwSgRCxh7El0=; b=roiYxljUzJ3J++rlHT1Sy5wnWXyijCY5x8Bt5TpQa4bRhXpfJesNnx7lMLn2etG0zT r8CwYaIU3riUDDCZ5nBt+TiDwilG8VovJHFg0sWP9CBrROi85BAULgXoC+iBi5s75sxd mfrEXg2VfsWfYJHE6y6ie83oUJGD0PTJghFFpzzf5IP8ZmmCoOwAaOZzmPhRPovqjLZV KUJZG/ltHsW3c7YxpiSYxFxZeJZJdqgrNKvMRCIGDcL9lpb4yyFl9HaZKHsnXfnh6nlY JOxldPPzsrGku+X4E/tQ3uShzQUnmSO5TKytzDmYVa+1FpGiaDGUdMgyWK1UqgHf8E1M OVXg== 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:cc:content-transfer-encoding; bh=MIPbFjVY++6vKQbewaqtkKG97IWh1StdwSgRCxh7El0=; b=Gabpj3DN0O/7IIdglAmnwr4QmQpbSH44tJlp4LyCl07GsQUxqdD8U1MkMzeVFWDrHN NGJCLS2pI8aTkBAvqas68U2/qET6VSKje1lfOKUiC7r8PP/qdj4ax5x9Fxh1aZDj5QVl ajzjdXprJzCI4k4Z2FO/ijzt1JhcL2R+2I1ut0bc0LAwedsMYlR1iaPfhfNzwp1/4+/g npXPa2KwonnKBYqJimY18tYUkOUXQ3MVViuf8Xl6uHP7Tgmj8JhJwao+B+tpCIxF5Gqy t0Ro3o/+uP9mITbZ0SJMlrXqHV1nuT597icwgk/2nFbLeyn3DpoX44kXqBlGDPejq3Lb VSfw== X-Gm-Message-State: ALyK8tJO/qcHbm0SR7HD0ZRbqxWrX2e4ntoOyTeLj7vAC3MiJqbC4wS84x0bJK9jtJGCUCfpugGfnv4HZTaULQ== X-Received: by 10.194.70.41 with SMTP id j9mr2342564wju.30.1467110100770; Tue, 28 Jun 2016 03:35:00 -0700 (PDT) In-Reply-To: <01ed522b-71d6-4535-8d49-b0e32c33ee3a@googlegroups.com> 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: <8a53c069-ca13-47bf-a24e-d2393a018b22@googlegroups.com> <576fd6e0$0$1617$c3e8da3$5496439d@news.astraweb.com> <2588c5b2-4b6f-cfbb-f91e-4db03aa50318@icloud.com> <8fbe89a6-c273-0fc9-820b-6ac629e6e769@gmail.com> <02e2d3f4-0198-4cdf-a493-45a248c03aea@googlegroups.com> <577129e0$0$1596$c3e8da3$5496439d@news.astraweb.com> <5771cd54$0$1589$c3e8da3$5496439d@news.astraweb.com> <4805e31e-040d-4caf-a79e-af56f93f6daf@googlegroups.com> <57720e58$0$1530$c3e8da3$5496439d@news.astraweb.com> <3bd25897-8ecb-4a27-ab22-220677551f41@googlegroups.com> <01ed522b-71d6-4535-8d49-b0e32c33ee3a@googlegroups.com> Xref: csiph.com comp.lang.python:110678 On Tue, Jun 28, 2016 at 6:49 PM, Lawrence D=E2=80=99Oliveiro wrote: > On Tuesday, June 28, 2016 at 7:26:30 PM UTC+12, Chris Angelico wrote: >> Why not: >> >> if (error) goto cleanup; >> ... >> cleanup: >> do_cleanup; > > They all fall into that same trap. Doesn=E2=80=99t scale. Try one with al= location inside a loop, e.g. lines 488 onwards. How is that different? You can use a goto inside a for loop just fine. (You can even, if you are absolutely insane and begging to be murdered by the future maintainer, use a goto outside a for loop targeting a label inside. See for example Duff's Device, although that's a switch rather than an actual goto.) You have a loop, and inside that loop, the exact same error handling pattern; so it should be possible to perform the exact same transformation, albeit with a differently-named local cleanup label. So, yes. It doesn't scale, if by "scale" you mean "so many separate local instances of error handling that you lose track of your cleanup labels". But you should be able to keep half a dozen labels in your head (if they're named appropriately), and if you have that many local error handlers, you probably want something to be refactored. ChrisA