[Python-Dev] Adding a conditional expression in Py3.0
Jim Jewett
jimjjewett at gmail.com
Wed Sep 21 00:50:22 CEST 2005
Guido van Rossum:
> I think I'd prefer (if <expr> then <expr> else <expre>)
In isolation, (if .. then ... else) is an improvement, but I'm
not sure it should be viewed in isolation.
At one point, you wanted to strengthen the distinction
between statements and expressions. Is that still true?
x = (if y then y.val else default)
x = (if y:
y.val
else:
default)
If any statement can become an expression, that could be very useful.
There are times when it would be convenient to just grab the newly
created function (def replacing lambda) or class, or the newly imported
module. The distinction between exec and eval starts to look
increasingly arbitrary as well.
But if everything becomes expression-able, people *will* start to
use parentheses instead of indentation.
-jJ
More information about the Python-Dev
mailing list