For review: PEP 308 - If-then-else expression

Paul Moore gustav at morpheus.demon.co.uk
Sun Feb 9 09:52:09 EST 2003


Erik Max Francis <max at alcyone.com> writes:

> Paul Moore wrote:
>
>> y = [sqrt(max(z, 0.0)) for z in x]
>> 
>> If you think this is a little too obscure, add a comment. I'm assuming
>> that you'd object to a suggestion that you define a safe_sqrt()
>> function which returns zero for negative numbers...
>
> Why do people keep looking for a magic bullet that will be an expression
> that clearly _must_ be expressed with a conditional operator?  

Because they can't make their point any other way. Oh, hang on - you
didn't notice that the people putting up the expressions which keep
getting shot down are the pro-PEP people...

The burden of proof is on those who want this change - justify it.

> Obviously no such thing exists; anything you can write with a
> conditional operator can be rewritten in some other syntax in
> currently-existing Python.
>
> That's not the point.  The point is whether or not the use of the
> conditional operator in those cases is justified and helps readability. 

Agreed.

> You may not think that in the sqrt case it is more readable, but it
> is at least somewhat readable if you know what a conditional
> operator is. The point is _not_ whether or not such a thing can be
> recasted in some other form.

You've *still* not presented an argument in favour of the proposition
that "the use of the conditional operator in those cases is justified
and helps readability".

I'm not trying to persuade you that conditional expressions are wrong
(or even that they are not useful on occasion). I'm simply pointing
out that you've not made a single argument in favour of them that
holds any water.

Your opinion differs from mine. That's fine. But let's not pretend
that anyone is saying anything persuasive...

Paul.
-- 
This signature intentionally left blank




More information about the Python-list mailing list