PEP 308 - ternary operator

Nick Trout nickNOSPAMtrout at shaw.ca
Sun Feb 16 21:45:30 CET 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E4FF0C1.70E9CFB9 at alcyone.com...
> Nick Trout wrote:
>
> > I think the definition of short circuiting is a little blurred. I
> > think it
> > basically means you dont want to evaluate the to values before you
> > return
> > one of them, which I don't believe I'm doing in either case.
>
> When you explicitly have to defer execution, like you did in the second
> case, that doesn't qualify as short circuiting.  In short circuiting the
> evaluation is implicit.

Oh okay.

> result = {True: math.sqrt(x), False: 0}[x >= 0]
>
> Even when you defer it with an explicit function call, the _value_ is
> still executed, it's just that the value is now a function.

Well what about extending the syntax of above to allow short-circuits and
then you'd get switch statements and ternary operators out of it? :)










More information about the Python-list mailing list