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


Groups > comp.lang.python > #81822

Re: Proposed new conditional operator: "or else"

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!roy
From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Proposed new conditional operator: "or else"
Date Tue, 02 Dec 2014 20:49:04 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Lines 32
Message-ID <roy-A42A43.20483402122014@news.panix.com> (permalink)
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com> <CAKJDb-NpPbsHgQw5PVtjyK352=zuSBeXJD_+dH5GH3niQDaSOQ@mail.gmail.com> <mailman.16498.1417544472.18130.python-list@python.org>
NNTP-Posting-Host localhost
X-Trace reader1.panix.com 1417571344 27428 127.0.0.1 (3 Dec 2014 01:49:04 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Wed, 3 Dec 2014 01:49:04 +0000 (UTC)
User-Agent MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Xref csiph.com comp.lang.python:81822

Show key headers only | View raw


In article <mailman.16498.1417544472.18130.python-list@python.org>,
 Chris Angelico <rosuav@gmail.com> wrote:

> On Wed, Dec 3, 2014 at 4:41 AM, 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?
> 
> Definitely. That's what I first thought, when I saw the subject line.
> 
> Additionally, whenever this construct is used, the "yield" statement
> (expression, whatever) will be redefined to yield to intimidation and
> make the statement true, whatever it takes. In the above example,
> "yield" would decide which out of foo and 42 is more amenable to
> change, and altering it to be equal to the other. (It may also find
> that == is the most amenable, and alter its definition such that foo
> and 42 become equal.)
> 
> ChrisA

This could be handy in the field of forensic accounting.

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


Thread

Re: Proposed new conditional operator: "or else" Chris Angelico <rosuav@gmail.com> - 2014-12-03 05:12 +1100
  Re: Proposed new conditional operator: "or else" Roy Smith <roy@panix.com> - 2014-12-02 20:49 -0500

csiph-web