For review: PEP 308 - If-then-else expression

Damien Morton newsgroups1 at bitfurnace.com
Sat Feb 15 05:10:13 EST 2003


"Stephen Horne" <intentionally at blank.co.uk> wrote in message
news:huvr4vs9bc1vgtrhq1m3hvgv7e6lkvig5h at 4ax.com...
> On Sat, 08 Feb 2003 11:02:49 -0800, Erik Max Francis <max at alcyone.com>
> wrote:
>
> >but there's no
> >reaosn there couldn't be other ternary operators having nothing to do
> >with the conditional operator.
>
> What a horrible thought! Next, you'll be suggesting quaternary
> operators!
>
> (sorry)


I was wondering about this too, but I cant think of any operator other than
conditional selection that requires short circuit evaluation.

That said, the chaining of conditional selection operations qualifies as a
higher than ternary operator.

Im still of the opinion that an operator akin to the C ternary operator,
which is available in all of the commonly used and taught languages (C, C++,
Java, C#, Javascript), is the way to go.

example:

sign = (x<0?-1 : x>0?1 : 0)

or

sign = (x<0?-1, x>0?1, 0)

or

sign = ?(x<0:-1, x>0:1, 0)








More information about the Python-list mailing list