[Python-Dev] Adding a conditional expression in Py3.0
Alexander J. Kozlovsky
kozlovsky at mail.spbnit.ru
Thu Sep 29 22:23:02 CEST 2005
Guido van Rossum wrote:
> I did this for my favorite proposal, and ended up with the list shown
> further down below.
>
> I think they all looks great!
I'm sorry for my bad English
IMHO, if condition is nontrivial, then the syntax:
expr1 if some complex condition else expr2
can be more hard to read as compared with:
if some complex condition then expr1 else expr2
In the second form visual comparison of expr1 and expr2 is simpler
because its adjacent placement. For example, in expression
'DO' if cmd == DO and flag == OK or x is None else 'DONT'
'DO' and 'DONT' visually divided and eyes must move there and back
for find the difference between them. As opposite, in expression
if cmd == DO and flag == OK or x is None then 'DO' else 'DONT'
it is very easy to determine what is possible expression output.
It is a bit more readable from my point of view
Best regards,
Alexander mailto:kozlovsky at mail.spbnit.ru
More information about the Python-Dev
mailing list