Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!reality.xs3.de!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'debugging': 0.07; 'occasionally': 0.09; 'raises': 0.09; 'python': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'pressed': 0.16; 'traceback.': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'bit': 0.19; '(in': 0.22; "i've": 0.25; 'header:In-Reply- To:1': 0.27; 'statement': 0.30; 'usually': 0.31; 'accidentally': 0.31; 'perl': 0.31; 'continuing': 0.33; 'but': 0.35; 'cancel': 0.36; 'dies': 0.36; 'charset:us-ascii': 0.36; 'received:10': 0.37; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'previous': 0.38; 'to:addr:python.org': 0.39; 'subject:"': 0.60; 'most': 0.60; 'fashion': 0.64; 'received:46': 0.66; 'subject:else': 0.84 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1417607819501:2707047459 X-MC-Ingress-Time: 1417607819501 Date: Wed, 3 Dec 2014 05:59:28 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Proposed new conditional operator: "or else" In-Reply-To: <1o2t7a5rt5j35lm8e5ad2811cpoupbs22f@4ax.com> References: <1o2t7a5rt5j35lm8e5ad2811cpoupbs22f@4ax.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-AuthUser: 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417608313 news.xs4all.nl 2832 [2001:888:2000:d::a6]:43138 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81857 On 2014-12-02 23:05, Dennis Lee Bieber wrote: > > foo == 42 or else > > Has a PERL stink to it... like: foo == 42 or die This statement actually works in Python and I occasionally use it when debugging (in the same fashion as one might do printf() debugging in C). It raises a NameError and the program dies with a traceback. Most frequently, it's to prevent the program from continuing on to connect to a database and actually make changes. I've grown up a bit and usually use pdb.set_trace() now, but it's still in my grab-bag of tools. -tkc [sorry for the previous message if I failed to cancel the send that happened when I accidentally pressed ctrl+enter...typing in the dark]