Anybody working on a PEP308 summary?

Giles Brown giles_brown at hotmail.com
Sun Feb 9 12:29:12 CET 2003


Isn't part of the purpose of a PEP to discuss the motivation for the
change.
It is my opinion that this PEP needs a better section on the
motivation. A
clear and objective list of the current means of achieving the same
effect.
I.e.

Technique number 1:

x = condition and expr1 or expr2

Which as we all now know (I guess?) fails in case of bool(expr1) being
False.

Technique number 2:

if condition:
    x = expr1
else:
    x = expr2

Which is three extra lines and suffers from the possibility of
introducing
a bug through mis-typing x.  

I believe the points in this post (so far) are objective arguments for
the PEP.  I also believe that the PEP should describe these
motivations.  Any other
relatively objective motifications should also be included.

Warning: from here on in is my opinion (so I'm happy for you to ignore
it :-)

Technique number 1 is a hack.  I'm not saying I don't use it, but it
is a hack.
Technique number 2 is clearly not. I'm not swayed at all by the saving
three lines argument.  I do have some sympathy for the bug through
mis-typing x argument,
but this is outweight by my lack of sympathy for what looks like a VI
caps lock
accident.  The damage to readability of the proposed syntax does not
(IMO)
outweigh the risk of misnaming the variable.  
Note I am also of the opinion that list comprehensions look like a VI
caps lock
accident, but as Aahz mention are a case of practicality winning out. 
They
also have the advantage of looking like an expression because they are
always
surrounded by [].




More information about the Python-list mailing list