Voting for PEP 308 (was Re: For review: PEP 308 - If-then-else expression)
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Tue Feb 11 19:25:14 EST 2003
> From: Hans Nowak [mailto:wurmy at earthlink.net]
>
> Hmm, what if bools grew an if() method? We could then write:
>
> z = (x == y).if(whentrue, whenfalse)
>
> This strikes me as much more elegant than the other proposals.
This seems like a very elegant and pythonic proposal. It does however suffer from two problems:
1. It doesn't short-circuit. As such it could not be an alternative for PEP 308 (which specifies short-circuiting).
2. Can't use `if` as a method name. But perhaps `test`? Or something along those lines?
I would *seriously* encourage you to write up a PEP for this - ASAP. This is the *only* ternary proposal I have seen yet that I would support.
Tim Delaney
More information about the Python-list
mailing list