Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'plenty': 0.07; 'assuming': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'iterate': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'sure,': 0.09; 'testing,': 0.09; 'wrong,': 0.09; 'year?': 0.09; '~ethan~': 0.09; 'bug': 0.12; 'accident.': 0.16; 'does,': 0.16; 'intended.': 0.16; 'loop.': 0.16; 'skipped': 0.16; 'skipping': 0.16; 'worse.': 0.16; 'zeros': 0.16; 'wrote:': 0.18; 'figures': 0.19; 'written': 0.21; '>>>': 0.22; 'header:User-Agent:1': 0.23; '31,': 0.24; 'lets': 0.24; 'skip': 0.24; 'earlier': 0.24; 'possibly': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'went': 0.31; 'code': 0.31; 'getting': 0.31; '(maybe': 0.31; '(since': 0.31; 'testing.': 0.31; "we're": 0.32; 'fri,': 0.33; 'not.': 0.33; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'right?': 0.36; 'done': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'starting': 0.37; 'expected': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'track': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'received:173': 0.61; "you're": 0.61; 'more': 0.64; 'taking': 0.65; 'occur': 0.65; 'talking': 0.65; 'results': 0.69; 'ending': 0.78; 'darn': 0.84; 'ethan': 0.84; 'furman': 0.84; 'safer': 0.84; 'silently': 0.84; 'uptime': 0.84; 'hand,': 0.93; 'imagine': 0.93; '2013': 0.98 Date: Thu, 30 May 2013 09:30:11 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Short-circuit Logic References: <5f101d70-e51f-4531-9153-c92ee2486fd9@googlegroups.com> <51a1fc7b$0$30002$c3e8da3$5496439d@news.astraweb.com> <2abf4e9c-8c3b-4e2f-80c9-50c1f1d75c9d@googlegroups.com> <51a4b5a1$0$29966$c3e8da3$5496439d@news.astraweb.com> <04b90c02-833a-4bad-88ad-ab71178b8f79@googlegroups.com> <51a6df59$0$11118$c3e8da3@news.astraweb.com> <51A769F2.1050702@stoneleaf.us> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([10.1.74.105]) [173.12.184.238]:50204 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369932811 news.xs4all.nl 15993 [2001:888:2000:d::a6]:53906 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46510 On 05/30/2013 08:56 AM, Chris Angelico wrote: > On Fri, May 31, 2013 at 1:02 AM, Ethan Furman wrote: >> On 05/30/2013 05:58 AM, Chris Angelico wrote: >>> If you iterate from 1000 to 173, you get nowhere. This is the expected >>> behaviour; this is what a C-style for loop would be written as, it's >>> what range() does, it's the normal thing. Going from a particular >>> starting point to a particular ending point that's earlier than the >>> start results in no iterations. The alternative would be an infinite >>> number of iterations, which is far far worse. >> >> If the bug is the extra three zeros (maybe it should have been two), then >> silently skipping the loop is the "far, far worse" scenario. With the >> infinite loop you at least know something went wrong, and you know it pretty >> darn quick (since you are testing, right? ;). > > You're assuming you can casually hit Ctrl-C to stop an infinite loop, > meaning that it's trivial. It's not. Not everything lets you do that; > or possibly halting the process will halt far more than you intended. > What if you're editing live code in something that's had uninterrupted > uptime for over a year? Doing nothing is much safer than getting stuck > in an infinite loop. And yes, I have done exactly that, though not in > Python. Don't forget, your start/stop figures mightn't be constants, > so you might not see it in testing. I can't imagine ANY scenario where > you'd actually *want* the infinite loop behaviour, while there are > plenty where you want it to skip the loop, and would otherwise have to > guard it with an if. We're not talking about skipping the loop on purpose, but on accident. Sure, taking a system down is no fun -- on the other hand, how much data corruption can occur before somebody realises there's a problem, and then how long to track it down to a silently, accidently, skipped loop? -- ~Ethan~