How do you get the logical xor of two variables in Python?
For example, I have two variables that I expect to be strings. I want to test that only one of them contains a True value (is not None or the empty string):
strng1 = raw_input("string one:")
strng2 = raw_input("string two:")
if logical_xor(strng1, strng2):
The ^ operator seems to be bitwise, and not defined on all objects:
>>> 1 ^ 1
>>> 2 ^ 1
>>> "pqr" ^ ""
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'str' and 'str'