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

Russell E. Owen owen at nojunk.invalid
Sat Feb 8 13:39:17 EST 2003


+1 from me.

- The construct is fairly self-explanatory.
- The construct is often useful, e.g. to set a variable to some value or 
other depending on conditions. In such a case it is simpler and less 
error-prone than multi-line if/then/else (does that variable really get 
set in all cases? hmm...let me see... ).

Also, as Andrew Koenig said so well:
>My evidence that it is important is that (a) people keep asking for
>it; (b) people keep thinking up circumlocutions to accomplish the
>same thing; and (c) those circumlocutions are often either wrong
>or hard to understand or remember.

Regarding the alternate suggestion of "where". I personally feel "where" 
implies some sort of looping, so I find "if" clearer. In any case, 
adding keywords is nearly anathema.

-- Russell




More information about the Python-list mailing list