[Python-Dev] conditional expressions?
Tim Peters
tim.one@home.com
Tue, 16 Oct 2001 00:41:50 -0400
[Daniel Mahler]
> Has an if(cond,exp1,exp2) syntax been considered?
Not seriously, no. That looks like a function call, and function arguments
are always evaluated in Python, and that works against seeing this as a
short-circuiting construct:
q = if y then x/y else copysign(INFINITY, x)
> It would have the advantage that existing
> syntax sensitive editors would handle without change.
I don't see any problem there (and am responsible for two context sensitive
Python edit gimmicks, and used to be responsible for a third -- all I expect
to need to do is get "then" at token level colored as keyword).
> I think conditional exprs badly needed,
> but the if/then/else syntax seems too verbose for use inside
> expressions.
Good -- then you won't be tempted to abuse it <0.5 wink>.
best-in-small-doses-ly y'rs - tim