missing 'xor' Boolean operator

Emile van Sebille emile at fenx.com
Wed Jul 15 13:55:22 EDT 2009


On 7/15/2009 10:43 AM Jean-Michel Pichavant said...
> Hrvoje Niksic wrote:
> [snip]
>> Note that in Python A or B is in fact not equivalent to not(not A and
>> not B).
>>   
>  >>> l = [(True, True), (True, False), (False, True), (False, False)]
>  >>> for p in l:
> ...     p[0] or p[1]
> ...
> True
> True
> True
> False
>  >>> for p in l:
> ...     not(not p[0] and not p[1])
> ...
> True
> True
> True
> False
>  >>>     
> Did I make twice the same obvious error ?

No -- but in the not(not... example it doesn't short-circuit.

Emile




More information about the Python-list mailing list