PEP308 - preference for 'x if c else y' over 'c then x else y'

Andrew Koenig ark at research.att.com
Sun Feb 16 19:40:29 EST 2003


Stephen> Yes - as I said in my post, and as you even included in the quote...

Stephen> (except
Stephen> in that lazy evaluation can ignore subexpressions which are
Stephen> not needed, but which might otherwise trigger errors).

Stephen> In your example, if e(x) is true, f(x) is not needed as it cannot
Stephen> affect the result - but its evaluation could trigger an error.

Stephen> So what are you contradicting me on, exactly?

If lazy evaluation can ignore unneeded subexpressions, but is not
required to do so, then you have the uncomfortable situation that
your program might fail on one implementation but not on another.

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list