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


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

Re: Proposed new conditional operator: "or else"

Started byTim Chase <python.list@tim.thechases.com>
First post2014-12-02 12:30 -0600
Last post2014-12-02 20:39 +0200
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" 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

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

FromTim Chase <python.list@tim.thechases.com>
Date2014-12-02 12:30 -0600
SubjectRe: Proposed new conditional operator: "or else"
Message-ID<mailman.16499.1417544855.18130.python-list@python.org>
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


[toc] | [next] | [standalone]


#81809

FromMarko Rauhamaa <marko@pacujo.net>
Date2014-12-02 20:39 +0200
Message-ID<8761dtuc9d.fsf@elektro.pacujo.net>
In reply to#81808
Tim Chase <python.list@tim.thechases.com>:

>> >    foo == 42 or else
>
> 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."

I would consider vain threats an antipattern.


Marko

[toc] | [prev] | [standalone]


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


csiph-web