[Python-Dev] conditional expressions?
Greg Ewing
greg@cosc.canterbury.ac.nz
Wed, 17 Oct 2001 13:51:39 +1300 (NZDT)
Guido:
> Someone else:
>
> > I was its only fan within PythonLabs, and I was lukewarm. The trick is to
> > view "if c else" as a new short-circuiting infix binary operator (for each
> > c), and then it makes great-- even elegant --sense.
I think it makes sense in its own right -- no need for
"tricks".
> Also I believe it would create a parsing problem in list
> comprehensions;
>
> [x for x in range(10) if small else range(100)]
Parentheses would need to be required in that case:
[x for x in (range(10) if small else range(100))]
I don't see that as a big problem -- wanting to put a conditional
expression in that position is going to be fairly rare.
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg@cosc.canterbury.ac.nz +--------------------------------------+