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: 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 To: python-list@python.org Subject: Re: When to use assert In-Reply-To: References: <528871d5$0$29975$c3e8da3$5496439d@news.astraweb.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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 p oimport pdb; pdb.set_trace() nnoremap P Oimport pdb; pdb.set_trace() 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