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

Andrew Dalke adalke at mindspring.com
Sat Feb 8 03:58:43 EST 2003


Andrew Koenig:
> Yes, they could be -- but in the process of translating the code, you
> inverted the condition!  The original yields "en" if mode_wanted is
> true, and the rewrite yields "en" if mode_wanted is false.

Indeed, as did Carel Fellinger elsewhere the first time she tried to
use it.  So if/else is, for the results of an expression, less prone to
error.

Though with some cases, as in

  is_html = True
  ext = ["txt", "html"][is_html]

the result is easy to understand.

> To me, that fact is a strong argument in favor of PEP 308 :-)

Hmmm...

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list