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

holger krekel pyth at devel.trillke.net
Sat Feb 8 10:15:28 EST 2003


Andrew Koenig wrote:
> Erik> That's exactly my view, as well.  I would prefer `if p then x
> Erik> else y', but if an extra keyword is absolutely contradindicated,
> Erik> then I'll settle for `x if p else y'.  I just want the
> Erik> functionality, I can learn to use the syntax.
> 
> I find one aspect of this discussion particularly interesting:
> 
> Most of the people in favor of PEP 308 have a pretty good idea of the
> contexts in which they want to use conditional expressions.
> 
> Most of the people opposed to PEP 308 are giving purely subjective
> reasons, disliking the whole idea so much that not only do they not
> want to use it, but they want to prevent other people from doing so as
> well.

Let me guess which side you lean on :-)

Actually, in my book people gave quite some good reasons 
for opposing the PEP:

    a) it reads ugly especially in non-assignment statements

    b) it reuses a keyword which formerly was a clean indicator
       of a statement

    c) you can't read it either LtR or RtL 

    d) there are often better ways than doing the C-ish
       'x ? y : z' 
    
    e) adds to the stuff you have to learn if you read others code

    f) is not an important enough use case to warrant new syntax

And i probably forgot others.  

> I've seen conflicts like this in other contexts; they're often a
> symptom of two subsets of the community that come from different
> backgrounds and want to program in different styles.

I have often seen people claiming that other people's objections
are just based on irrational feelings whereas themselves they 
would have well-founded oppinions :-)

More seriously, though, i think you are right about pythoneers
coming from different backgrounds.  But it's important to 
settle on a *minimal* set of syntax and not combine all the 
wishes from all "groups" which would greatly decrease readability 
of other's source code. 

    holger





More information about the Python-list mailing list