[Python-ideas] except expression

Georg Brandl g.brandl at gmx.net
Thu Feb 13 15:53:48 CET 2014


Am 13.02.2014 12:25, schrieb spir:

> [By the way, this shows that:
> 	x = b if cond else a
> should really be:
> 	x = a else b if cond
> The difference being that the standard case is expressed first, the exceptional 
> one being then introduced as an special variant.]

No it shouldn't -- your syntax associates "b" with both the else ("else b") and
the "if" clause ("b if cond"), which makes me think "which of them will it be".

Also, there's nothing intrinsically more "exceptional" about the "if" branch
than the "else" branch; this entirely dependent on the expression.

Georg



More information about the Python-ideas mailing list