[Python-ideas] XOR

Dj Gilcrease digitalxero at gmail.com
Wed Oct 28 00:03:29 CET 2009

On Tue, Oct 27, 2009 at 4:46 PM, Sturla Molden <sturla at molden.no> wrote:
> Sturla Molden skrev:
>> Why does Python have a bitwise but not a logical xor operator? It's even
>> weirder because boolean objects do have a __xor__ method.
>>>> True.__xor__(False)
> True
>>>> True xor False
> SyntaxError: invalid syntax
> Doesn't this look like a case for new syntax before the moratorium?

No the proper syntax is

>>>False ^ False
>>>False ^ True
>>>True ^ False
>>>True ^ True

More information about the Python-ideas mailing list