Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.055 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'before.': 0.16; 'cc:name:python list': 0.16; 'executed.': 0.16; 'pdb;': 0.16; 'roy': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'cc:addr:python.org': 0.22; 'stick': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'on,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'probably': 0.32; 'not.': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'so,': 0.37; 'being': 0.38; 'rather': 0.38; 'either': 0.39; 'remove': 0.60; 'more': 0.64; 'smith': 0.68; 'oscar': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=2GDTvPsynsAMO5A3Tm9liu0zYveiu1WdIQxzGrggrhU=; b=td0VoBFPxF9nPmIwbUAwS7ilUpcEWTks2MeZaUszIUBjkRNJ9bcyr8aHqtXtatYx/l hrBWhPnV8f8fWGdnFZLnzonaQL51MnTEgfluQpjBDhg/W/QTNJRdXjvSFb9+N6nQfFJG lvqqLzI9YPONF/uomkEEjFTySOYsS1UBy+oP58ub/c5C7rZsPYUCG3MIYGnN3UpatvQ4 uLucA4ymoPDkI8OO+MyRqbH7IJoq8NsHL/WJpEHL2Tvp8pwah8E+MJ9J5vQJWuf7qK3z 7Oa3LuAg+/L2AsDv/SiuSihOE0mW7IDsAI2i+6ooxffFU63UqyLNo4nmccPVQKxZXXED Ndbw== X-Received: by 10.220.144.18 with SMTP id x18mr14704263vcu.15.1384768232106; Mon, 18 Nov 2013 01:50:32 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <528871d5$0$29975$c3e8da3$5496439d@news.astraweb.com> From: Oscar Benjamin Date: Mon, 18 Nov 2013 09:50:11 +0000 Subject: Re: When to use assert To: Roy Smith Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384768239 news.xs4all.nl 15937 [2001:888:2000:d::a6]:55384 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59844 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