For review: PEP 308 - If-then-else expression
ark at research.att.com
Sat Feb 8 00:31:21 CET 2003
Skip> On Fri, 7 Feb 2003, Guido van Rossum wrote:
>> The proposed syntax is as follows:
>> <expression1> if <condition> else <expression2>
Skip> +0 from me. For the times I've needed such a construct
Skip> <cond> and <expr1> or <expr2>
Skip> has generally been sufficient.
except that this construct has a subtle pitfall: If <cond> is true
and <expr1> is false, the result is <expr2> instead of <expr1>.
To get around it, you have to write something like
(<cond> and [expr1] or [expr2])
which is truly obscure.
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list