[Python-Dev] Adding a conditional expression in Py3.0

Terry Reedy tjreedy at udel.edu
Wed Sep 21 20:41:39 CEST 2005


When you invited resumed discussion, did you intend to proceed from where 
the revised PEP left off (with a few variations on the table), or to start 
over from point zero (with potentially anything and everything on the 
table).  In particular, do we need to rehash the reasons for rejection of 
the backwards if-else proposal that a few seem to wish to resurrect?

Many people, perhaps most, including me, read

exp1 if exp2 else exp3 # as
cond if etrue else efalse # in direct analogy with
cond ?  etrue :     efalse # from C

I mentally read ?: in C as if/else!  It took a few readings of the proposal 
to even realize that it the order flipped.

There there is the obvious analogy with Python's
if cond: etrue
else:      efalse
with 'if' moved over to the first : position (and the : then removed) but 
with 'else' still between the alternatives (and the second : also removed).

Then there are conditional functions, in various languages, iff(cond, 
etrue, efalse), which as far as I know always have the expressions in that 

Need I continue?  Or is the dead still dead?

Terry J. Reedy

More information about the Python-Dev mailing list