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

François Pinard pinard at iro.umontreal.ca
Fri Feb 7 21:19:50 EST 2003


> >     The proposed syntax is as follows:
> > 
> >         <expression1> if <condition> else <expression2>

[Paul Rubin]

> I have to say this sounds excessively Perlish, putting the condition
> after the first expression like that.

We have an important precedent in Python, in the form of list comprehension,
where `if' and `for' are appended to the expression.

While I appreciate the list comprehension feature, which might be very
useful at times, it is also far too easily abused into writings which lack
legibility.  I fear a bit that PEP 308 suggestion has the same benefits and
pitfalls, that is, it might be useful at times, but also may be abused.

In Python 1.5.2, the language was kind of protective against such abuse.
Now, legibility relies more on the shoulders of the programmer and less on
the language itself.  That turn having already been taken by Python, my
guess is that PEP 308 suggestion would currently fit well.  My reluctance to
it comes more from some remaining nostalgia of previous Python simplicity,
and nowadays, should probably be dismissed as anachronic! :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list