Proposed PEP for a Conditional Expression

Tim Hammerquist tim at vegeta.ath.cx
Tue Sep 11 01:48:44 EDT 2001


Me parece que thp at cs.ucr.edu <thp at cs.ucr.edu> dijo:
> Bernhard Herzog <bh at intevation.de> wrote:
> [...]
> : Another way that come to mind:
> 
> :         <expr> if <cond> else <expr>
> 
> : The order in which the condition and the braches occur is unusual for
> : python, but this spelling has the advantage of not needing an additional
> : keyword or colons.
> 
> I strongly favor the inclusion of a short-circuiting conditional
> operator, and I think that the above syntax is probably the best
> suggestion, since it closely resembles colloquial English and accepted
> mathematical terminology for piecewise definitions, without
> introducing new lexemes into the language.  E.g., the phrase
> 
>              "one if by land, two if by sea"
> 
> translates to 
> 
>               1 if by_lang() else 2 if by_sea() else 0

http://www.perl.org/

[ snip ]

-- 
Watch my captor grow old and die.
No satisfaction. Still here.
    -- Morpheus, The Sandman



More information about the Python-list mailing list