Another conditional expression candidate (PEP 308)

Anders J. Munch andersjm at dancontrol.dk
Mon Feb 10 03:51:13 EST 2003


"Roy Smith" <roy at panix.com> wrote in message
news:roy-0250BA.18571809022003 at reader1.panix.com...
> Evan <evan at 4-am.com> wrote:
>
> > x = (if a > 0: 'positive' elif a == 0: 'zero' else: 'negative')
> >
> > The parentheses and 'else:' clause are mandatory.  Leave them off and
> > you get a SyntaxError.
>
> Why is the else: manditory?  Why not have it return None if none of the
> conditions are true?

Let's take one thing at a time.  You can always propose this in a later PEP.

- Anders






More information about the Python-list mailing list