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


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

Re: Proposed new conditional operator: "or else"

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2014-12-02 23:05 -0500
Last post2014-12-02 23:05 -0500
Articles 1 — 1 participant

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" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-12-02 23:05 -0500

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

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-12-02 23:05 -0500
SubjectRe: Proposed new conditional operator: "or else"
Message-ID<mailman.16511.1417579537.18130.python-list@python.org>
On Tue, 2 Dec 2014 12:18:36 -0500, Roy Smith <roy@panix.com> declaimed the
following:

>In the process of refactoring some code, I serendipitously created what I think is an essential new bit of Python syntax.  The “or else” statement.  I ended up with:
>
>        sites_string = args.sites or else self.config['sites']
>
>which, of course, is a syntax error today, but it got me thinking what we could do with an “or else” construct.  Perhaps an alternative to assertions?  Wouldn’t it be neat to write:

	Well -- currently, since Python does short circuit conditionals, ALL
"or" conditions are the equivalent of "or else" (which is an Ada construct:
A or B evaluates both sides, A or else B only evaluates B if A is false.
The converse operation in Ada is and then: A and then B)

>
>   foo == 42 or else
>

	Has a PERL stink to it... like: foo == 42 or die
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [standalone]


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


csiph-web