Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81821

Re: Proposed new conditional operator: "or else"

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'explicit': 0.07; '"or': 0.09; 'executed': 0.09; 'false.': 0.09; 'happen,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'else"': 0.16; 'evaluates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'dec': 0.30; 'statement': 0.30; 'assert': 0.31; 'guess': 0.33; 'but': 0.35; 'false': 0.36; 'should': 0.36; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'subject:"': 0.60; 'for:': 0.64; 'it!': 0.67; 'smith': 0.68; 'subject:else': 0.84; 'ware': 0.91; 'write:': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Sturla Molden <sturla.molden@gmail.com>
Subject Re: Proposed new conditional operator: "or else"
Date Wed, 3 Dec 2014 00:54:26 +0000 (UTC)
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 211-185-11.connect.netcom.no
User-Agent NewsTap/4.0.1 (iPad)
X-
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16505.1417568083.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417568083 news.xs4all.nl 2895 [2001:888:2000:d::a6]:44350
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81821

Show key headers only | View raw


Zachary Ware <zachary.ware+pylist@gmail.com> wrote:
> On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith <roy@panix.com> wrote:
>> Wouldn’t it be neat to write:
>> 
>>    foo == 42 or else
>> 
>> and have that be an synonym for:
>> 
>>     assert foo == 42
>> 
>> :-)
> 
> Never going to happen, but I like it!  Perhaps raise IntimidationError
> instead of AssertionError when it fails?

I guess the "or else" statement should do this:

   <condition> or else <threat>

where the statement <threat> is executed if the statement <condition>
evaluates to false.

In absence of an explicit threat

  <condition> or else

it should raise IntimidationError if <condition> evaluates to false false.

If <condition> evaluates to true it should just return <conditon>.



Sturla

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Proposed new conditional operator: "or else" Sturla Molden <sturla.molden@gmail.com> - 2014-12-03 00:54 +0000

csiph-web