Ternary Operator

Alex Martelli aleaxit at yahoo.com
Fri May 18 13:00:27 EDT 2001


"Stefan Kirchberg" <sk at gluit.de> wrote in message
news:3B054397.71A1A29F at gluit.de...
> Hi,
>
> I just read section 4.16 of The Whole Python FAQ
> (http://www.python.org/doc/FAQ.html#4.16). It states that as an
> equivalent to C/C++'s
>         a? b : c
    ...
> Now, how about
>         [b,c][not a]

Doesn't short-circuit -- b and c both get evaluated
no matter what.  Not a good idea if translating
    a? (1/a) : 0.23
for example.


Alex






More information about the Python-list mailing list