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

Sean Ross sross at connectmail.carleton.ca
Fri Feb 7 17:43:31 EST 2003


In this particular case, I'd say it's significantly better...

> if x when C else y:
>     pass
>
> as opposed to:
>
> if x if C else y:
>     pass

If this is to be in the language, wouldn't you rather avoid the latter case
above?
If the language adds this construct,  I would argue that since python
already has
a use for if, I think it would be less confusing to have a new word for this
new syntax.

On a different front:

if C?x:y:
    pass

is just nasty...

And, now that I've thought on it some more, I don't care for my other
suggestion much either:

    when C, x else y

but, I'm just tossing things out there...

Sean

"Bjorn Pettersen" <BPettersen at NAREX.com> wrote in message
news:mailman.1044654498.10428.python-list at python.org...
> From: Sean Ross [mailto:frobozz_electric at hotmail.com]
>
> >
> >     The proposed syntax is as follows:
> >
> >         <expression1> if <condition> else <expression2>
> >
>
> While I do not think this is necessary, I would like to offer
> an alternative
> syntax:
>
>     <expression1> when <condition> else <expression2>
[...]
> Although adding a keyword is often a bad thing...

In fact, most of the time it makes it a non-starter. FWIW, I don't think
it is significantly better than if either (sorry).

-- bjorn






More information about the Python-list mailing list