Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68009

Re: Assertions are bad, m'kay?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.041
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'article.': 0.16; 'cc:name:python list': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'post': 0.26; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'fri,': 0.33; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'read': 0.60; 'mar': 0.68; 'url:676': 0.84
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:to :cc:content-type; bh=3FPRQWAWe7d3XJhIhnfZ755pXs9inPRcxCxQ6SKO3o0=; b=Yf6GscTX3bayk/1JodUUuecQVBvJAMOkSbLvoAWTGalrZh+icvzUHPJTsIFnf5UHK6 tMDjZhjQfI3XTH5KUicS4r/Mdz199AwVWK3maXD9jldmdf5gCooP3cJ8Q58iqVo5FK/y o94EsN7vpTCj8CdQ0+EkMZDnyD1irojs89nYhUPW23tDFD9hrhvY++D8L9HwWIPCstYt 9tWYtFin/SkIf+Y1/8rKDsxVLfw1oiFbuSVnQOiiEsKcBdrkdsjJ22YsnV6mzOR4I3FY epuebL3mnDC+WYxcdCx2W3j2jj7M44HEZ9NI3KpF3qbUlnR8CsS4wy7EuyJVvOgFwYqn rN5A==
MIME-Version 1.0
X-Received by 10.180.106.40 with SMTP id gr8mr767231wib.31.1394237736536; Fri, 07 Mar 2014 16:15:36 -0800 (PST)
In-Reply-To <5319a975$0$29985$c3e8da3$5496439d@news.astraweb.com>
References <mailman.7890.1394176617.18130.python-list@python.org> <5319a975$0$29985$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 7 Mar 2014 16:15:36 -0800
Subject Re: Assertions are bad, m'kay?
From Dan Stromberg <drsalists@gmail.com>
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type text/plain; charset=ISO-8859-1
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7909.1394237738.18130.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1394237738 news.xs4all.nl 2851 [2001:888:2000:d::a6]:47143
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68009

Show key headers only | View raw


On Fri, Mar 7, 2014 at 3:11 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:

>
> Assertions are not bad! They're just misunderstood and abused.

> You should read this guy's blog post on when to use assert:
>
> http://import-that.dreamwidth.org/676.html

Nice article.

BTW, what about:

if value >= 3:
   raise AssertionError('value must be >= 3')

?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Assertions are bad, m'kay? Chris Angelico <rosuav@gmail.com> - 2014-03-07 18:16 +1100
  Re: Assertions are bad, m'kay? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-07 11:11 +0000
    Re: Assertions are bad, m'kay? Chris Angelico <rosuav@gmail.com> - 2014-03-07 22:24 +1100
    Re: Assertions are bad, m'kay? Dan Stromberg <drsalists@gmail.com> - 2014-03-07 16:15 -0800
      Re: Assertions are bad, m'kay? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2014-03-08 01:26 +0100
      Re: Assertions are bad, m'kay? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-08 14:44 +0000
    Re: Assertions are bad, m'kay? Ben Finney <ben+python@benfinney.id.au> - 2014-03-08 11:22 +1100

csiph-web