Albert van der Horst wrote:
Remains whether we need an xor that only works and requires that
both operands are booleans. That one we have already!
It is called != .
(a!=b)!=c
and
a!=(b!=c)
are the same for booleans, so can indeed be expressed
a!=b!=c (associativy of xor)
Not in Python
>>> a,b,c = True, False, True
>>> (a!=b)!=c
False
>>> a!=(b!=c)
False
>>> a!=b!=c
True
>>> (a!=b) and (b!=c)
True
In Math and Python, a<b<c means a<b and b<c, not (a<b)<c or a<(b<c).
!= is a comparison operator like <, not an arithmetic operator like +
(or logical xor). If one has 0/1 or True/False values, we have
arithmetic xor already, ^, which works as expected.
>>> (a^b)^c
False
>>> a^b^c
False
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list