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


Groups > comp.lang.python > #81829

Re: Proposed new conditional operator: "or else"

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Proposed new conditional operator: "or else"
Date 2014-12-02 23:05 -0500
Organization IISS Elusive Unicorn
References <C2BEED98-4CCA-4EDE-8FDF-F235B478055C@panix.com>
Newsgroups comp.lang.python
Message-ID <mailman.16511.1417579537.18130.python-list@python.org> (permalink)

Show all headers | View raw


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/

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


Thread

Re: Proposed new conditional operator: "or else" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-12-02 23:05 -0500

csiph-web