Proposed PEP for a Conditional Expression

Michael Chermside mcherm at destiny.com
Thu Sep 13 17:22:34 EDT 2001


> If it does not conflict with
> the existing grammar, I would go for
> 
> <condition> if <expression a> else <expression>
> 
> as being a Pythonic translation of ? : constructions since I read ? as
> 'if' and : as 'else'.
> 
> Terry J. Reedy

But that appears to NOT scan like English.

    x = finished() if 'Done' else nextValue()

It seems to me that the word "if", in English, can be used in may 
flexible ways:

    "one if by land two if by sea"

    "if you're ready then we'll go, otherwise we'll stay here"

But I can't think of a use in which "if" isn't immediately followed by 
the condition.

-- Michael Chermside






More information about the Python-list mailing list