Another conditional expression candidate (PEP 308)
evan at 4-am.com
Mon Feb 10 14:58:47 CET 2003
Alan Daniels wrote:
> Am I missing something? The whole point of a ternary operator is to
> save you extra typing.
No. If that were the whole point then the idea would have died long
ago. It's about clarity of expression.
> Also, I think this would also be VERY confusing to new users.
> This would be legal syntax:
> result = if cond: x else: y
> But this...
> result = if cond:
> ...would be illegal
This is part of why I suggested mandatory parens. Then both of these
are legal, and there is no confusion:
result = (if cond: x else: y)
result = (if cond:
Evan @ 4-am
More information about the Python-list