On Tue, Oct 27, 2009 at 5:13 PM, Sturla Molden email@example.com wrote:
I think you are missing the point: ^ is bitwise or. Don't think we can always go from bitwise to boolean operator by casting to bool. Xor is a special case.
No you cannot always go from bitwise to logical, but in the xor case it works, which is the case you were wanting to add syntax for. Just because it is also bitwise syntax does not mean you cannot use it in logical operations where it is intended to work.
The only benefit I see to adding xor is not having to cast items to a bool before doing the test, which could be solved with no syntax changes by adding the __xor__ method to the types you want to check, though I think adding this to builtins would fall under the moratorium.
could define __xor__ for all objects, except where the bitwise xor is intended as
def __xor__(self, other): return bool(self) ^ bool(other)