conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))
Greg Ewing
greg at cosc.canterbury.ac.nz
Wed Oct 17 20:57:44 EDT 2001
John Roth wrote:
>
> "Paul Boddie" <paul at boddie.net> wrote in message
> news:23891c90.0110170317.1e18fae5 at posting.google.com...
> >
> > It seems to me, from code I've seen and written, that the C- and
> > Java-style ... ? ... : ... construct is most frequently used in cases
> > where one is testing for NULL (or null)
>
> Many instances of this are already handled by the short-circuit
> 'and' and 'or' operators. These operators have well-known
> deficiencies...
Maybe we could do with an operator like 'or' except
that it compares its first operand with None instead
of just testing it for trueness. I suggest
x else y
or, if you want to keep 'else' for a possible future
reconsideration of if-then-else and don't mind a new
keyword,
x otherwise y
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list