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


Groups > comp.lang.python > #81808

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.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '"or': 0.09; 'definition,': 0.09; 'don': 0.09; 'happen,': 0.09; 'cc:addr:python-list': 0.11; 'thread': 0.14; '"assert"': 0.16; '-tkc': 0.16; 'else"': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'gonna': 0.16; 'received:10.216': 0.16; 'roy': 0.16; ':-)': 0.16; 'language': 0.16; 'wrote:': 0.18; '(not': 0.18; '(in': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'words': 0.29; 'dec': 0.30; 'statement': 0.30; 'assert': 0.31; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:10': 0.37; 'subject:new': 0.38; 'even': 0.60; 'subject:"': 0.60; 'for:': 0.64; 'to:addr:gmail.com': 0.65; 'it!': 0.67; 'optimized': 0.68; 'smith': 0.68; 'subject:else': 0.84; 'ware': 0.91; 'write:': 0.91
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 1417544851181:422902027
X-MC-Ingress-Time 1417544851181
Date Tue, 2 Dec 2014 12:30:00 -0600
From Tim Chase <python.list@tim.thechases.com>
To Zachary Ware <zachary.ware+pylist@gmail.com>
Subject Re: Proposed new conditional operator: "or else"
In-Reply-To <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com>
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.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=UTF-8
Content-Transfer-Encoding quoted-printable
X-AuthUser tim@thechases.com
Cc Python <python-list@python.org>
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.16499.1417544855.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417544855 news.xs4all.nl 2926 [2001:888:2000:d::a6]:37299
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81808

Show key headers only | View raw


On 2014-12-02 11:41, Zachary Ware 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?

In light of the parallel thread discussing the "assert" statement
and the perils of trusting it to be present even though it can be
optimized away, this "or else" could be (in the altered words of Don
Corleone), "I'm gonna make an assertion he can't refuse."

(not that I particularly want/expect this in the language definition,
but it's fun to entertain the idea)

-tkc


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


Thread

Re: Proposed new conditional operator: "or else" Tim Chase <python.list@tim.thechases.com> - 2014-12-02 12:30 -0600
  Re: Proposed new conditional operator: "or else" Marko Rauhamaa <marko@pacujo.net> - 2014-12-02 20:39 +0200

csiph-web