conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))

John Roth johnroth at
Wed Oct 17 19:16:05 CEST 2001

"Paul Boddie" <paul at> wrote in message
news:23891c90.0110170317.1e18fae5 at
> 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.

John Roth

More information about the Python-list mailing list