Proposed PEP for a Conditional Expression

Bernhard Herzog bh at intevation.de
Wed Sep 12 13:22:50 EDT 2001


"Terry Reedy" <tjreedy at home.com> writes:

> "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 must admit that I don't like it myself for exactly this reason. This
construct is non unusual in natural language, though (at least in
English and German) which is probably the reason why perl has something
like it.

> 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>

To me it that's twice backwards but unfortunately in this case that
doesn't make it forwards :-)

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                               http://mapit.de/



More information about the Python-list mailing list