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


Groups > comp.lang.python > #59851

Re: When to use assert

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.045
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; 'insert': 0.05; '-tkc': 0.16; 'benjamin': 0.16; 'executed.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'pdb': 0.16; 'pdb;': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'header:In-Reply- To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'file': 0.32; 'probably': 0.32; 'but': 0.35; 'charset:us-ascii': 0.36; 'being': 0.38; 'saves': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'easy': 0.60; 'more': 0.64; 'quality': 0.72; 'hassle.': 0.84; 'oscar': 0.84; 'received:50.22': 0.84
Date Mon, 18 Nov 2013 05:44:58 -0600
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: When to use assert
In-Reply-To <CAHVvXxQYwgnmDw48kdFw258v6Sf_+2gnZna8_=0-_t_4xSduCA@mail.gmail.com>
References <528871d5$0$29975$c3e8da3$5496439d@news.astraweb.com> <roy-8BDD06.08334817112013@news.panix.com> <CAHVvXxQYwgnmDw48kdFw258v6Sf_+2gnZna8_=0-_t_4xSduCA@mail.gmail.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: authenticated_id: tim@thechases.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.2835.1384775012.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384775012 news.xs4all.nl 15924 [2001:888:2000:d::a6]:50209
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59851

Show key headers only | View raw


On 2013-11-18 09:50, Oscar Benjamin wrote:
> 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*.

I do this so much that on my main development machines, I have a line
in my vimrc file

  nnoremap <leader>p oimport pdb; pdb.set_trace()<esc>
  nnoremap <leader>P Oimport pdb; pdb.set_trace()<esc>

which maps the the leader key (defaults to "\") followed by p/P to
insert the pdb line below/above the current line.  Saves bunches of
time & hassle.  I'm sure it's equally easy in other quality editors.

-tkc


Back to comp.lang.python | Previous | NextPrevious 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