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


Groups > comp.lang.python > #59846

Re: When to use assert

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'from:addr:yahoo.co.uk': 0.04; 'insert': 0.05; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'python': 0.11; 'before.': 0.16; 'benjamin': 0.16; 'executed.': 0.16; 'pdb;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'do,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'stick': 0.24; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'on,': 0.29; 'code': 0.31; 'probably': 0.32; 'not.': 0.33; "i'd": 0.34; 'something': 0.35; 'but': 0.35; 'combination': 0.36; 'so,': 0.37; 'being': 0.38; 'christian': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'remove': 0.60; 'world.': 0.61; 'more': 0.64; 'smith': 0.68; 'cut': 0.74; 'oscar': 0.84; 'received:2': 0.84; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: When to use assert
Date Mon, 18 Nov 2013 10:02:39 +0000
References <528871d5$0$29975$c3e8da3$5496439d@news.astraweb.com> <roy-8BDD06.08334817112013@news.panix.com> <CAHVvXxQYwgnmDw48kdFw258v6Sf_+2gnZna8_=0-_t_4xSduCA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-202-11.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
In-Reply-To <CAHVvXxQYwgnmDw48kdFw258v6Sf_+2gnZna8_=0-_t_4xSduCA@mail.gmail.com>
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.2830.1384768972.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384768972 news.xs4all.nl 15942 [2001:888:2000:d::a6]:32828
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59846

Show key headers only | View raw


On 18/11/2013 09:50, Oscar Benjamin wrote:
> On 17 November 2013 13:33, Roy Smith <roy@panix.com> wrote:
>>
>> So, I stick "assert 0" in the code an re-run the program to see if I get
>> an AssertionError.  If I do, then I know the code is being run.  If I
>> don't then I know it's not.  Either way, I know more about what's going
>> on than I did before.  Once I know what's going on, I remove the assert.
>
> If the program is invoked from a terminal I would probably go with
> 'import pdb; pdb.set_trace()' rather than 'assert 0'. Then you can
> check much more than whether or not the code is being executed. It's a
> bit more to type but I type it so often that I can now type it *really
> fast*.
>
>
> Oscar
>

If I used something that often I'd either cut and paste it or have a key 
combination set up to insert it automatically.  Or get my man to type it 
up for me :)

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Thread

When to use assert Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-17 07:35 +0000
  Re: When to use assert Tim Chase <python.list@tim.thechases.com> - 2013-11-17 06:50 -0600
    Re: When to use assert Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-18 00:52 +0000
  Re: When to use assert Roy Smith <roy@panix.com> - 2013-11-17 08:33 -0500
    Re: When to use assert Robert Day <robertkday@gmail.com> - 2013-11-18 08:20 +0000
    Re: When to use assert Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-11-18 09:50 +0000
    Re: When to use assert Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-18 10:02 +0000
    Re: When to use assert Tim Chase <python.list@tim.thechases.com> - 2013-11-18 05:44 -0600

csiph-web