Update to PEP308: if-then-else expression
sismex01 at hebmex.com
sismex01 at hebmex.com
Tue Feb 11 10:52:06 EST 2003
>
> So I must say that I *strongly* favor:
>
> result = x==21 ?? x*2 || 42
>
That's way ugly, even for C/C++ syntax.
In C, this is perfectly valid:
x = w + s ? a : b + k;
but it's pretty hard to parse on sight, it's
vastly better to write:
x = w + (s ? a : b) + k;
YES, it is a contrived and simpleminded example,
but requiring parenthesis around the conditional
expression (or printing a warning when compiling
one without, warning of possible ambiguities) will
keep python easy on the eyes, and shut up all
detractors which base their arguments on possible
confusion and loss of readability.
-gustavo
More information about the Python-list
mailing list