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

Paul Paterson hamonlypaulpaterson at
Sun Feb 9 21:23:16 CET 2003

"Alex Martelli" <aleax at> wrote in message
news:Z_x1a.157670$0v.4413687 at
> Piet van Oostrum wrote:
>    ...
> > If b is a variable that takes only 0 and 1 as values then
> >
> > b -> (x, y) is the same as
> > b -> [y, x]
> >
> > because with boolean conditionals people are used to have the true
> > first. And we shouldn't change that.
> Argh -- I had missed that.  OK, then I don't like the proposal any
> more -- having to switch order of x and y depending on what
> parentheses you use would make the construct unusable IMHO, and,
> without the generality of being able to use it in the integer
> case, I don't think the usefulness is sufficient to warrant a
> new operator.  Pity:-(.

You could view it that in one form (boolean) you are selecting and in the
other (integer) you are indexing, which would give,

print x>0 -> (sqrt(x), 0)
print (val1, val2, val3) <- x

The <- would imply lazy evaluation of the preceeding tuple, this
distinguishing it from

print (val1, val2, val3)[x]

More information about the Python-list mailing list