For review: PEP 308 - If-then-else expression
Andrew Dalke
adalke at mindspring.com
Mon Feb 10 13:24:05 EST 2003
Alan Daniels:
> For what it's worth, here's what I want to
> see in a ternary operator:
>
> 1) Is readable and obvious, for people both with and without
> backgrounds in C.
> 2) Gets the "cond" part of it first, just like in Python's
> current use of the "if" keyword.
> 3) Doesn't break the meaning of any existing constructs.
To which I'll add:
4) is conducive to the development of a community guideline
for when it is appropriate to use this operator vs. an if/else
statement. ("There should be one-- and preferably only one
--obvious way to do it.")
5) is not likely to have people use it instead of other, better
Python constructs.
I don't believe #4 exists for C/C++, and I believe #5 is not
true (that is, that people will, with some regularity, use the
if/else operator when a better solution exists, and for which
an if/else statement was an equally good solution).
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list