Proposed PEP for a Conditional Expression
Michael Chermside
mcherm at destiny.com
Thu Sep 13 17:29:38 EDT 2001
> SPEC_6: Use condition as index of tuple.
> The currently legal syntax "x =
> (false_val(),true_val())[cond]" would be used, but now
> short-circuit.
This would seem to me to be a complete non-starter, since it changes the
behavior of tuples into some wierd version of a lazy list. It would
completely and fundamentally change things deep in the heart of Python,
and probably NOT necessarily in a positive way.
> SPEC_7: Use condition as index "of" tuple.
> The syntax "x = cond of (false_val(),true_val())"
> would be used.
It sounds like what you're trying to invent here is a short-circuiting
CASE expression, not a conditional expression. That seems out of scope,
and so I'm inclined to ommit this one. Please, though, let me know if
I'm misunderstanding you.
-- Michael Chermside
More information about the Python-list
mailing list