For review: PEP 308 - If-then-else expression
Paul Moore
gustav at morpheus.demon.co.uk
Sat Feb 8 16:02:14 EST 2003
Andrew Koenig <ark at research.att.com> writes:
> I *do* mind it, for two reasons:
>
> 1) It puts the false condition ahead of the true condition.
This one I agree with. cond-true-false is the only order that I can
see as readable, in the long run. (Which, unfortunately, isn't the one
in the PEP...)
> 2) It evaluates both alternatives even though only one is needed.
I'd like to see some concrete examples of where this is a significant
issue. All the examples so far have been "toy" ones, where performance
isn't an issue, and I have a hard time thinking of a case where only
evaluating one alternative is needed for *correctness* (unlike C,
where i < MAX_BOUND ? array[i] : default is the obvious example).
Paul
--
This signature intentionally left blank
More information about the Python-list
mailing list