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

Georg Mischler schorsch at schorsch.com
Sun Feb 9 17:42:18 EST 2003


François Pinard wrote:

>> >     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.

And that's why I'm really glad that list comprehensions *require*
the [brackets] around them. They tell the reader that there is
something slightly unusual going on inside. In a way, list
comprehensions are a seperate language within the language.

In contrast, the strange sequence of conditional and expressions
proposed in this PEP can almost appear anywhere in the code
without the slightest visual warning. That looks like very
dangerous territory to me.

Any syntax that puts the elements in the intuitive order will be
less error prone, and several sensible variations have already
been posted.


-schorsch

-- 
Georg Mischler  --  simulations developer  --  schorsch at schorsch com
+schorsch.com+  --  Lighting Design Tools  --  http://www.schorsch.com/




More information about the Python-list mailing list