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

Guido van Rossum guido@python.org
Wed, 17 Oct 2001 13:27:04 -0400


I guess I've lost track of all the proposals here; what's the current main proposal?

(if cond then expr else expr) with mandatory parentheses?

Almost -- the parentheses can be left out in some cases, e.g.

x = if 1 then 2 else 3

I agree with Greg Wilson that elif should be added too.

not too bad -- but I doubt it will save me much time in real life... (probably a net loss: even if I could use this from time to time, it's not like I have to use much brain- power to spell it out in today's python...)

That's my conclusion too. I went looking through the stdandard library for places that could use it and basically didn't find any in the 15 minutes before I got bored.

So the patch is still there but this won't make it into 2.2.

--Guido van Rossum (home page: http://www.python.org/~guido/)