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

Richard Jones rjones at ekit-inc.com
Sat Feb 8 04:03:04 CET 2003


On Sat, 8 Feb 2003 1:51 pm, Carlos Ribeiro wrote:
> On Saturday 08 February 2003 02:32 am, Andrew Koenig wrote:
> > Carlos> I don't think that the code above is much clearer than the
> > Carlos> one-liner with the ternary operator.
> >
> > My experience is that when people say "x is much clearer than y",
> > what they are really saying is often "x is more familiar than y".
>
> I fully agree with you - in fact, I think that most people that reacted
> today (tonight?) against the PEP are just reacting because the new syntax
> is not familiar to them, and the step-by-step evaluation is.

Not at all. I believe the opposing reactions are far more varied and far 
deeper than the superficial theory you're pushing here.

The main concerns I see are:

1. Python already has the required functionality, just in another form (ie. 
not as an expression, but as a statement)
2. A lot of people have a real problem with the "value is this.... er, except 
when it's not and then it's this" ... ie. when quickly parsing the code, the 
value appears to be one thing, but then you're presented with a test which 
indicates that it may not - the code "branches" _after_ you've specified the 
value that may or may not be the result of the expression. The statement form 
of "if/elif/else" is much clearer - you do the test first, and the results of 
the test are perfectly clear.

Nothing to do with the new expression syntax not being familiar, or 
comfortable.


    Richard






More information about the Python-list mailing list