Defending the ternary operator
Erik Max Francis
max at alcyone.com
Sat Feb 8 15:56:19 EST 2003
Alexander Schmolck wrote:
> True. Still, that doesn't mean that allowing further grammatically
> distinct
> "if"s wouldn't have a negative impact. The list comprehension "if" at
> least is
> quite limited: there is no "else" part, you can't chain it and it
> occurs in a
> fairly narrow context. Introducing an "if" expression would almost
> certainly
> increase the impact:
>
> if ...:
> y = [i if ... else ... for i if i ...] if ... else ...
Yep, language features can be abused. That's true for any language
feature in any language. I don't find it a compelling argument,
especially in this case where the construct being proposed has the
opportunity make code _more_ clear and concise when used properly, not
less.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Lawyers, I suppose, were children once.
\__/ Charles Lamb
The laws list / http://www.alcyone.com/max/physics/laws/
Laws, rules, principles, effects, paradoxes, etc. in physics.
More information about the Python-list
mailing list