boolean xor

Dieter Deyke Dieter_Deyke at CoCreate.com
Sun Jan 7 14:01:18 EST 2001


Try

	((not a) != (not b))

aahz at panix.com (Aahz Maruch) writes:

> 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

-- 
Dieter Deyke
mailto:Dieter_Deyke at CoCreate.com mailto:deyke at crosswinds.net
Vs lbh pna ernq guvf, lbh unir jnl gbb zhpu gvzr.



More information about the Python-list mailing list