Proposed PEP for a Conditional Expression

Markus Schaber markus at schabi.de
Mon Sep 17 09:06:29 EDT 2001


Hi,

Skip Montanaro <skip at pobox.com> schrub:

> 
>     Markus> What about "(<cond>: return <expr> [else return <expr])"
> 
> All you're saving is a single word and a colon:
> 
>     if <cond>: return <expr>
>     else: return <expr>

But my version doesn't overload the if keyword, the second proposal 
doesn't overload the if and return keywords.

And with requiring the brackets, it should be easier for machine and 
human parsers to distinguish between the if: else: statements and the 
conditional expression.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list