Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.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: OK 0.033 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'assuming': 0.09; 'correct,': 0.09; 'logic': 0.09; 'violates': 0.09; 'cc:addr :python-list': 0.11; 'abusing': 0.16; 'arg': 0.16; 'assumptions': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; '(by': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'assert': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'checking': 0.33; 'fri,': 0.33; 'common': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; 'does': 0.39; 'most': 0.60; 'between': 0.67; 'mar': 0.68; '10:11': 0.84; 'asked.': 0.84; 'whereas': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=PQW1qOOYB7N8Ohnk62GeJWgI/vOeD5eZMjr3JZFx7mY=; b=Rv0fLlREDexFMFyKRSLKl4Kr8Xp15olMF70EtcqT1bmbAqS6R/VfIUkm+ZPsUuxqpP B0MM7DwogJW4IQ9fMuw+68WF7Q3uXxHJAzsIZ47kpFIQdgr9Y7BMdUui45pCLDnK4+DQ EzfZUYzHhmWm4ad8yGqqdQeQeGVHuY71S/pIm8t4YuzsgM53bKBqZRrdeIDGZvmYUpvL fXYDdKd/pQ2Sls3PETRbUZYgujHGsoDpl8IkDeBoygPCGSZOMUFz/Lvee9cmuzSV9LwX dtb0l/BOnCfAJMwyc0/00UTmmHYeC9vnNX1C73Wda9EZjkUMoI2hgHGlVbSHglBYFZj9 axVg== MIME-Version: 1.0 X-Received: by 10.69.25.69 with SMTP id io5mr21477432pbd.22.1394191469442; Fri, 07 Mar 2014 03:24:29 -0800 (PST) In-Reply-To: <5319a975$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <5319a975$0$29985$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 7 Mar 2014 22:24:29 +1100 Subject: Re: Assertions are bad, m'kay? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394191472 news.xs4all.nl 2833 [2001:888:2000:d::a6]:47960 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:67991 On Fri, Mar 7, 2014 at 10:11 PM, Steven D'Aprano wrote: >> http://xkcd.com/1339/ >> >> Abusing assert for arg checking violates XKCD 1339. Write >> standards-compliant code! > > Assertions are not bad! They're just misunderstood and abused. > > (By the way, assertions are not the same as assumptions. Asserts can be > used to check that assumptions are correct, or to check the internal > logic of your reasoning. Whereas assumptions are just accepted as if they > were correct, no questions asked. The XKCD does draw a distinction between assuming and asserting. And I do say "for arg checking", which is the most common *abuse* of assert. But mainly, I just like to share laughs :) ChrisA