PEP308: Yet another syntax proposal

Dave Brueck dave at pythonapocrypha.com
Mon Feb 10 15:35:36 EST 2003


On Mon, 10 Feb 2003, holger krekel wrote:

> > Short-circuit evaluation is never "necessary" in _any_ language - it's
> > just very, very useful sometimes. Python's 'and' operator doesn't _have_
> > to be a short-circuit operator, but it's far more useful because it is.
> >
> > > and therefore iif() unreasonable.
> >
> > Several of the previous examples have already illustrated this:
> >
> > z = iif(x, x.getPref(), 'Not specified')
> >
> > is broken without short-circuiting.
>
> yes, but it is easily written with an and-expression
>
>   z = not x and 'Not specified' or x.getPref()

Yikes! The above line of code is a great argument _in favor of_
if-expressions on the basis of readability and maintainability. I couldn't
encourage anyone to use that form.

> and a ternary op would simply add another possibility.

...and hopefully deprecate the usage of your above example, the "simulated
conditional expression".

-Dave





More information about the Python-list mailing list