conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))
johnroth at ameritech.net
Wed Oct 17 19:16:05 CEST 2001
"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) and producing an ad-hoc result
> in order to avoid writing a function which does such a test and
> returns the appropriate value. More advanced applications of the
> construct seem to me to be bad style, but perhaps I've never been
> exposed to "power users" of the construct along with their code.
Many instances of this are already handled by the short-circuit
'and' and 'or' operators. These operators have well-known
deficiencies with respect to a general conditional expression;
however, since they do handle many (possibly most) of the
cases of interest, it reduces the value of the conditional expression.
More information about the Python-list