
Nov. 26, 2009
10 p.m.
Alexander Belopolsky wrote:
On Tue, Oct 27, 2009 at 6:41 PM, Sturla Molden <sturla@molden.no> wrote:
Why does Python have a bitwise but not a logical xor operator?
.. because it does: !=
True != True False True != False True False != False False
In 2.x you can even use <> if you like syntactic sugar. :-)
On arbitrary types a xor b is arguably bool(a) != bool(b) rather than simple a != b, but it is rare enough to warrant additional syntax.
I thought I've seen this answered in an FAQ list somewhere.
I've seen this in Java. But the field is different there, with no operator overloading != is always be equivalent with logical XOR. I'm +0 on the proposal, for being very rarely needed.