[Python-Dev] conditional expressions - add parens? (original) (raw)

Alex Martelli aleaxit at gmail.com
Tue Mar 7 16:42:29 CET 2006


On Mar 7, 2006, at 7:29 AM, Steve Holden wrote: ...

In fact, I think the below examples are reasonable uses that do a better job of expressing intent than the if statement would. I just don't like the mental backtrack they require, and would like some sort of advance warning. Parentheses at least tell me "You're not done yet; keep reading."

ack(r,r) if r not in cache log(message) if errorflag I think you've misunderstood the nature of the change. HTe new conditionals are expressions, they aren't postfix conditionals for statements.

Right, but the only effect of that on the examples is that they both
need an 'else None' continuation or thereabouts.

I also predict widespread over-use of the new toy and agree with Jim
that mandatory parentheses around the whole (X if Y else Z) construct
would ameliorate legibility a bit.

Alex



More information about the Python-Dev mailing list