Looking thru decimal.py and it uses NotImplemented at many special methods e.g.
class A(object):
def __lt__(self, a):
return NotImplemented
def __add__(self, a):
return NotImplemented
NotImplemented: Special value which can be returned by the “rich comparison” special methods (eq(), lt(), and friends), to indicate that the comparison is not implemented with respect to the other type.
It doesn't talk about other special methods and neither describes the behavior
It seems to be a magic object which if returned from other special methods raises TypeError, and in “rich comparison” special methods does nothing
e.g.
print A() < A()
prints True, but
print A() + 1
raises TypeError, so I am curious whats going on and what is the usage/behavior of NotImplemented