Too much code - slicing

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Sep 20 20:07:07 EDT 2010


On Mon, 20 Sep 2010 19:28:49 +0200, Antoon Pardon wrote:

> Not necessarily. Some of us have the impression that Guido deliberatly
> chose an ugly format for the ternary operator.

If he did, then he must have changed his mind, because there is nothing 
ugly about the ternary operator we ended up with.


> Guido has alwasys been
> against a ternary operator but the requests kept coming. So eventually
> he introduced one. But the impression is that he chose an ugly format in
> the hope of discouraging people to use it.

That's sheer and unadulterated nonsense. The fact is that Guido changed 
his mind about ternary if after discovering that the work-around

true-clause and condition or false-clause

is buggy -- it gives the wrong answer if true-clause happens to be a 
false value like [], 0 or None. If I recall correctly, the bug bit Guido 
himself.

The and-or hack, which was *very* common in Python code for many years 
and many versions, follows the same pattern as ternary if:

true-clause if condition else false-clause

It astounds me how the Python community changed it's collective mind from 
admiration of the elegance and simplicity of the expression when it was a 
buggy hack, to despising it when it became a bug-free language feature.

Go figure.



-- 
Steven



More information about the Python-list mailing list