boolean xor

Aahz Maruch aahz at panix.com
Sun Jan 7 13:27:20 EST 2001


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



More information about the Python-list mailing list