class Node:
def __init__(self,a,b):
self._a=a
self._b=b
def __lt__(self,other):
return self._a<other._a
a=Node(1,2)
b=Node(0,4)
print(a>b)
The code above shows True.
class Node:
def __init__(self,a,b):
self._a=a
self._b=b
def __lt__(self,other):
return self._a<other._a
def __eq__(self,other):
return self._a==other._a
a=Node(1,2)
b=Node(0,4)
print(a>=b)
The code above shows TypeError: '<=' not supported between instances of 'Node' and 'Node.
Why defining only lt makes >(which is gt) operation possible? why defining both lt and eq makes <= impossible?