Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!feeder2-2.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:code': 0.07; 'executable': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'http': 0.09; 'message-id:@stoneleaf.us': 0.09; 'properly.': 0.09; '~ethan~': 0.09; 'django': 0.11; '>in': 0.16; 'dump': 0.16; 'middleware': 0.16; 'roy': 0.16; 'sense,': 0.16; 'subject:python': 0.16; 'exception': 0.16; 'followed': 0.16; ':-)': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'stack': 0.19; 'header:User-Agent:1': 0.23; '(or': 0.24; "i've": 0.25; 'world,': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; "d'aprano": 0.31; 'disable': 0.31; 'steven': 0.31; 'trace': 0.31; 'figure': 0.32; 'running': 0.33; 'checking': 0.33; 'but': 0.35; 'there': 0.35; 'doing': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'too': 0.37; 'clear': 0.37; 'being': 0.38; 'somebody': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'is.': 0.60; 'hope': 0.61; 'received:173': 0.61; "you're": 0.61; 'more': 0.64; 'great': 0.65; 'within': 0.65; 'yes': 0.68; 'circle': 0.68; 'smith': 0.68; 'strategies': 0.77; 'article': 0.77; 'happened.': 0.84; 'metaphor.': 0.84; 'standing': 0.84 Date: Mon, 23 Dec 2013 04:45:07 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: cascading python executions only if return code is 0 References: <52b782db$0$6599$c3e8da3$5496439d@news.astraweb.com> <52b7a0e4$0$29994$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:51662 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 2 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387804133 news.xs4all.nl 2964 [2001:888:2000:d::a6]:36998 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62623 On 12/22/2013 08:57 PM, Roy Smith wrote: > In article <52b7a0e4$0$29994$c3e8da3$5496439d@news.astraweb.com>, > Steven D'Aprano wrote: > >> Anyway, I may be completely misinterpreting what I'm reading. Perhaps the >> assertion is checking a function invariant ("one of the strategies will >> always succeed") in which case you're doing it exactly right and I should >> shut up now :-) > > Yes :-) > > More specifically, the assertion exception will get caught way up in > some django middleware which will log a stack trace and return a HTTP > 50-something. This will typically be followed by somebody like me > noticing the stack dump and trying to figure out WTF happened. This is completely misusing what assertions are for. I hope this bit of middleware (or django itself) is very clear about never running with assertions turned off. > Assertions are great tools. Only when used properly. >People should use them more often. I see them being (mis)used too much as it is. >In a > sense, they're executable comments. They're a programmer's way of > standing on a hilltop and shouting to all the world, "I swear to you, > this is true. There may be a gazillion lines of code out there and > GBytes of program state, but right here, right now, within this circle > I've drawn in the sand, Considering how easy it is to disable assertions, a circle in the sand is an amazingly appropriate metaphor. :) -- ~Ethan~