For review: PEP 308 - If-then-else expression
anthony at interlink.com.au
Mon Feb 10 01:06:17 CET 2003
>>> Piet van Oostrum wrote
> It just dawned on me that the 'if' is not really necessary.
> "->" would be a more pythonic operator than "?" I think, because it stands
> out more. And indeed it looks a bit strange to have the other part as a
> What about:
> condition -> (true part, false part)
> The (,) is not a tuple here but it belongs to the -> and the -> says to
> select one of the expressions based on the condition and evaluate that;
> kind of lazy indexing.
Hm. I quite like this. The new symbol is a visual clue that something's
going on (rather than re-using 'if', which I dislike strongly).
> We could then also have one for ints rather than bools:
> i -> [ v_0, v_1, v_2, ... ]
> which would pick v_i and evaluate that.
On the other hand, I don't like this. If you need to do something like
this, why not just
[ v_0, v_1, v_2, ... ][i] ?
Anthony Baxter <anthony at interlink.com.au>
It's never too late to have a happy childhood.
More information about the Python-list