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


Groups > comp.lang.python > #81807 > unrolled thread

Re: Proposed new conditional operator: "or else"

Started byChris Angelico <rosuav@gmail.com>
First post2014-12-03 05:12 +1100
Last post2014-12-02 20:49 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#81807 — Re: Proposed new conditional operator: "or else"

FromChris Angelico <rosuav@gmail.com>
Date2014-12-03 05:12 +1100
SubjectRe: Proposed new conditional operator: "or else"
Message-ID<mailman.16498.1417544472.18130.python-list@python.org>
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

[toc] | [next] | [standalone]


#81822

FromRoy Smith <roy@panix.com>
Date2014-12-02 20:49 -0500
Message-ID<roy-A42A43.20483402122014@news.panix.com>
In reply to#81807
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web