Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.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: UNSURE 0.266 X-Spam-Level: ** X-Spam-Evidence: '*H*': 0.49; '*S*': 0.03; 'causing': 0.04; 'responding': 0.07; 'worse': 0.09; 'posted': 0.15; 'incorrect': 0.16; 'relevance': 0.16; 'wrote:': 0.18; 'code.': 0.18; '>>>': 0.22; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'crash': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'handled': 0.32; 'running': 0.33; 'fri,': 0.33; 'programmers': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; '14,': 0.36; 'doing': 0.36; 'possible': 0.36; 'changing': 0.37; 'wrong': 0.37; 'so,': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'soon': 0.63; 'more': 0.64; 'different': 0.65; 'believe': 0.68; 'smith': 0.68; 'potentially': 0.81; 'assertion.': 0.84; 'ethan': 0.84; 'furman': 0.84; 'horrible': 0.84; 'improvement,': 0.84; 'optimized.': 0.84; 'preventing': 0.84; 'defeat': 0.91; 'novice': 0.91; 'thing,': 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 :content-type:content-transfer-encoding; bh=VMu0dtJPMWVKhsQ/ifgviuh/l4xXu1PpLBRGHsZd2rM=; b=eOVeu3djSzDA9FQbph+UKLiSaEb68L5C5u5gRetg3RgR5rzv3DsGqCCavFMdZj4/ej 8duDdHLBqt7fBNbMk2fB0sY5K4KnLXMfv6MnQVnBG/pfxBPgKe7qV7KA353WisBAdJ5K v8cQ4leCaxdvqXXx1NTmoyj/uo/IFfNGHWGd2OgE6801aIkAiyTwV4Sq0hM/P4xezAPt lQM8avVMLjSVJh3SzrTq2vwZInRRJCgfuT/P9YFNARk2ogJumxYwSiiUZuCDNjWcnMCV KNtfsLoEhVLi8Fagkzp4d91AVtsTGQWoGM/o7SttRT4Co/xJ9HLhUx6lf1i7hjPvNpla ZfRA== X-Received: by 10.70.47.195 with SMTP id f3mr3849682pdn.156.1415983256545; Fri, 14 Nov 2014 08:40:56 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <5465e963$0$13009$c3e8da3$5496439d@news.astraweb.com> References: <96c138e4-ab95-4e5f-a0c8-e696b5a926bb@googlegroups.com> <87a93wqeq3.fsf@elektro.pacujo.net> <87y4rgozgd.fsf@elektro.pacujo.net> <0cdc67f4-d9d5-4a73-91fe-7558161246af@googlegroups.com> <5465e963$0$13009$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Fri, 14 Nov 2014 09:40:16 -0700 Subject: Re: I love assert To: Python Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Fri, 14 Nov 2014 18:42:09 +0100 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415986930 news.xs4all.nl 2936 [2001:888:2000:d::a6]:54149 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80775 On Fri, Nov 14, 2014 at 4:37 AM, Steven D'Aprano wrote: > Ethan Furman wrote: > >>> There's no way to make the CONFUSED status be handled without actually >>> changing the code. The difference is that this version will not >>> incorrectly treat CONFUSED as WARNING; it just won't do anything at >>> all if the code is optimized. >> >> So, a different wrong thing, but still a wrong thing. ;) > > And potentially a *worse* wrong thing. Potentially it's worse, but more likely doing the wrong thing will be worse than doing nothing. > "I find it amusing when novice programmers believe their main > job is preventing programs from crashing. ... More experienced > programmers realize that correct code is great, code that > crashes could use improvement, but incorrect code that doesn=E2=80=99= t > crash is a horrible nightmare." > -- Chris Smith > > Assertions can help by this, by causing wrong code to fail as soon as > possible (provided, of course, that you don't defeat the assertions by > running the code with assertions disabled). I fail to see the relevance of this quote. The code I posted that you're responding to does use an assertion. The case where it does "a different wrong thing" is precisely the case where assertions are disabled.