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


Groups > comp.lang.python > #81808

Re: Proposed new conditional operator: "or else"

Date 2014-12-02 12:30 -0600
From Tim Chase <python.list@tim.thechases.com>
Subject Re: Proposed new conditional operator: "or else"
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16499.1417544855.18130.python-list@python.org> (permalink)

Show all headers | 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