Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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; 'syntax': 0.04; '"or': 0.09; 'currently,': 0.09; 'false.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; '"or"': 0.16; '>in': 0.16; 'construct.': 0.16; 'else"': 0.16; 'evaluates': 0.16; 'message- id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'refactoring': 0.16; 'roy': 0.16; 'statement.': 0.16; 'essential': 0.16; 'bit': 0.19; 'code,': 0.22; 'error': 0.23; 'url:home': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'dec': 0.30; '(which': 0.31; 'perl': 0.31; 'could': 0.34; 'created': 0.35; 'but': 0.35; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:"': 0.60; 'new': 0.61; 'today,': 0.61; 'smith': 0.68; 'circuit': 0.84; 'subject:else': 0.84; 'write:': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Proposed new conditional operator: "or else" Date: Tue, 02 Dec 2014 23:05:23 -0500 Organization: IISS Elusive Unicorn References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 108.68.179.184 X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417579537 news.xs4all.nl 2913 [2001:888:2000:d::a6]:44958 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81829 On Tue, 2 Dec 2014 12:18:36 -0500, Roy Smith declaimed the following: >In the process of refactoring some code, I serendipitously created what I think is an essential new bit of Python syntax. The “or else” statement. I ended up with: > > sites_string = args.sites or else self.config['sites'] > >which, of course, is a syntax error today, but it got me thinking what we could do with an “or else” construct. Perhaps an alternative to assertions? Wouldn’t it be neat to write: Well -- currently, since Python does short circuit conditionals, ALL "or" conditions are the equivalent of "or else" (which is an Ada construct: A or B evaluates both sides, A or else B only evaluates B if A is false. The converse operation in Ada is and then: A and then B) > > foo == 42 or else > Has a PERL stink to it... like: foo == 42 or die -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/