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: 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 Subject: Re: When to use assert Date: Mon, 18 Nov 2013 10:02:39 +0000 References: <528871d5$0$29975$c3e8da3$5496439d@news.astraweb.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: 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: 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 On 18/11/2013 09:50, Oscar Benjamin wrote: > On 17 November 2013 13:33, Roy Smith 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