(no) fast boolean evaluation ?

Laurent Pointal laurent.pointal at limsi.fr
Fri Aug 3 04:00:13 EDT 2007


Stef Mientki a écrit :
> hello,
> 
> I discovered that boolean evaluation in Python is done "fast"
> (as soon as the condition is ok, the rest of the expression is ignored).
> 
> Is this standard behavior or is there a compiler switch to turn it on/off ?

As it was replied, its standard behavior and cannot be modified.

IMHO, if you really need all your expressions to be evaluated, the clean 
(most readable) way may be:

a = <first_expression which must be evaluated>
b = <second_expression(x,y,z) which must be evaluated>
if a and b :
     ...

A+

Laurent.



More information about the Python-list mailing list