For review: PEP 308 - If-then-else expression

Erik Max Francis max at alcyone.com
Sun Feb 9 22:06:04 EST 2003


Andrew Koenig wrote:

> Me too.  But seriously, what's wrong with
> 
>     x = if y < 5: "Yep" else: "Nope"
> 
> I would hope the meaning is immediately obvious...

Nothing at all, I don't think.  I suggested it early on in the thread
(required parentheses or no), and it's been suggested independently (as
far as I can tell) at least two more times.  As someone pointed out,
some digging discovered that someone suggested it in a proposed PEP
which never went anywhere several years ago.

It seems to satisfy all the criteria:  reads left-to-right, is
unambiguous, is easy to understand, and requires no new keywords.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Patiently, I'm still / Holding out until
\__/ Sandra St. Victor
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.




More information about the Python-list mailing list