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

Paul Paterson hamonlypaulpaterson at houston.rr.com
Sun Feb 9 15:32:51 EST 2003


"Paul Paterson" <hamonlypaulpaterson at houston.rr.com> wrote in message
news:UMy1a.21480$%U2.1586379 at twister.austin.rr.com...
> "Alex Martelli" <aleax at aleax.it> wrote in message
> news:Z_x1a.157670$0v.4413687 at news1.tin.it...
> > 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
> clause
> > > 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]
>

Oops, this doesn't work of course since (1,2,3) <- 2 might mean "less than
minus 2"






More information about the Python-list mailing list