boolean xor

Steve Williams sandj.williams at gte.net
Sun Jan 7 17:03:30 EST 2001


Aahz Maruch wrote:

> I need a boolean (not bit-wise) xor function.  I've got the following
> function, but my logic skills are rusty enough that I'm wondering if
> this is the "right" way to do it (I've validated that it produces the
> correct outputs, at least):
>
> def xor(a,b):
>     return not ( (a and b) or (not (a or b)) )
> --
>                       --- Aahz (Copyright 2001 by aahz at pobox.com)
>
> Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
> Hugs and backrubs -- I break Rule 6
>
> "This is Usenet.  We're all masturbating in public places."  -DH

(A or B) and not (A and B) has fewer knots.  DeMorgans Law.




More information about the Python-list mailing list