PEP 308: Pep Update

John Roth johnroth at ameritech.net
Thu Feb 13 14:31:35 CET 2003


"Damien Morton" <newsgroups1 at bitfurnace.com> wrote in message
news:mailman.1045130444.14913.python-list at python.org...
> Id like to propose the desireability of any proposed conditional
selection
> expression syntax to handle multiple chained condition/value pairs.
>
> For the leading options offered, chaining them looks like this:
>
> STRICT INTERPRETATION
>
> (if <cond1>: <expr1> else: (if <cond2>: <expr2> else: <expr3>))
> (<cond1> then <expr1> else (<cond2> then <expr2> else <expr3>))
> (<cond1> ? <expr1> : (<cond2> ? <expr2> : <expr3>))
>
> RELAXED INTERPRETATION
>
> (if <cond1>: <expr1> elif: <cond2>: <expr2> else: <expr3>)
> (<cond1> then <expr1> elif <cond2> then <expr2> else <expr3>)
> (<cond1> ? <expr1> : <cond2> ? <expr2> : <expr3>)
>

I like the elif: version. There's a reason why many languages
do chained ifs that way: the nested "if" structure is too hard to
understand.

John Roth






More information about the Python-list mailing list