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

Andrew Dalke adalke at mindspring.com
Sat Feb 8 13:19:00 EST 2003


Sean Ross:
> Mostly, I just wanted to avoid a specific edge case someone mention much
> earlier in the thread:
>
>     if x if C else y:
>         ...do stuff...

Hmm... what if Python generates a "EleganceWarning" when it gets
an if expression in an if statement, or embedded if expressions?

>     Do you need this construct enough to put up with the potential abuses
it
> can bring?

No.  I know how much I abused it in my youth.  (But at least it
kept me off the streets!)

> Whatever you choose is fine with me. If I don't like it I won't use it. If
I
> do like it I will use it sparingly.
> But, if other people use it, I'll likely go mad...  just kidding ...

I believe there should be one prefered way for simple constructs like
this.  If if/else expression is added to the langauge, then it will be
because
people have deemed that the prefered way to write certain patterns.
And if it's the prefered way then, according to my beliefs, I should switch
to using it in all my code (and fixing up old code when it comes to
refactoring).

                    Andrew
                    dalke at dalkescientific.com







More information about the Python-list mailing list