(no) fast boolean evaluation ? missing NOT
S.Mientki-nospam at mailbox.kun.nl
Fri Aug 3 13:16:51 CEST 2007
Laurent Pointal wrote:
> Stef Mientki a écrit :
>> def Some_Function (const):
>> print 'Ive been here', const
>> return True
>> A = True
>> if A and Some_Function (4 ):
>> print 'I knew it was True'
>> print 'I''ll never print this'
>> Ive been here 4
>> I knew it was True
>> I was expected that the function would not be called,
>> because A is True.
> When using the *and* operator, the short-circuit evaluation is done if A
> is False (no need to know the other operand, the result cannot be True).
> But if A is True, the compiler must evaluate the second parameter to
> know the expression result.
Sorry you're completely right,
and indeed I must have something very stupid !!
thanks very much
More information about the Python-list