missing 'xor' Boolean operator

Lino Mastrodomenico l.mastrodomenico at gmail.com
Thu Jul 16 05:02:55 EDT 2009


2009/7/16 Hendrik van Rooyen <mail at microcorp.co.za>:
> "Hrvoje Niksic" <hniksic at x..s.org> wrote:
>
>
>> Note that in Python A or B is in fact not equivalent to not(not A and
>> not B).
>
> De Morgan would turn in his grave.

If this can make him happier, in Python (not (not a and not b)) *is*
equivalent to bool(a or b). (Modulo crazy things like redefining
"bool" or having a __bool__ with side effects.)

In the first expression you implicitly request a bool because you use
"not", in the second one you do this with an explicit "bool".

-- 
Lino Mastrodomenico



More information about the Python-list mailing list