missing 'xor' Boolean operator
Robert Kern
robert.kern at gmail.com
Tue Jul 14 16:59:32 EDT 2009
On 2009-07-14 14:56, Dr. Phillip M. Feldman wrote:
> != does do what I want, except that it doesn't indicate to someone reading
> the code that the operands are being treated as logicals. (Readability is
> supposed to be one of the major selling points of Python). But, this is
> probably good enough.
In the words of those greater than myself, "Not every one-liner needs to be in
the standard library."
def xor(a, b):
return bool(a) != bool(b)
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list