Proposed PEP for a Conditional Expression

Terry Reedy tjreedy at home.com
Wed Sep 12 13:12:06 EDT 2001


"Joshua Marshall" <jmarshal at mathworks.com> wrote in message
news:9nnsa3$bjl$1 at news.mathworks.com...
> thp at cs.ucr.edu wrote:
> > Bernhard Herzog <bh at intevation.de> wrote:
> > [...]
> > : Another way that come to mind:
>
> > :         <expr> if <cond> else <expr>
>
> One thing I don't like about this suggestion is that <cond> is
> evaluated before the first <expr> is [potentially] evaluated, even
> though <expr> syntactically precedes <cond>.

I agree that the above is backwards.
<cond> if <expr> else <expr>
would remove that objection and make the syntax parallel to
<cond> ? <expr> : <expr>

Terry J. Reedy





More information about the Python-list mailing list