class LikeDate:
def __eq__(self, other):
if isinstance(other, LikeDate):
return True
else:
return NotImplemented
def __ge__(self, other):
if isinstance(other, LikeDate):
return True
else:
return NotImplemented
class LikeInt:
def __eq__(self, other):
if isinstance(other, LikeInt):
return True
else:
return False
def __ge__(self, other):
if isinstance(other, LikeInt):
return True
else:
return NotImplemented
a = LikeDate()
b = LikeInt()
print(a == b) # False
print(a == 0) # False, because int provides an __eq__ method that returns False
print(a >= 0) # Error, because nether LikeDate nor int provides a definite comparison for __ge__
print(a >= b) # Error, because neither objects provide a comparable __ge__
CmNsYXNzIExpa2VEYXRlOgogICAgZGVmIF9fZXFfXyhzZWxmLCBvdGhlcik6CiAgICAgICAgIGlmIGlzaW5zdGFuY2Uob3RoZXIsIExpa2VEYXRlKToKICAgICAgICAgICAgIHJldHVybiBUcnVlCiAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgcmV0dXJuIE5vdEltcGxlbWVudGVkCiAgICBkZWYgX19nZV9fKHNlbGYsIG90aGVyKToKICAgICAgICAgaWYgaXNpbnN0YW5jZShvdGhlciwgTGlrZURhdGUpOgogICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICAgZWxzZToKICAgICAgICAgICAgICByZXR1cm4gTm90SW1wbGVtZW50ZWQKCmNsYXNzIExpa2VJbnQ6CiAgICBkZWYgX19lcV9fKHNlbGYsIG90aGVyKToKICAgICAgICAgaWYgaXNpbnN0YW5jZShvdGhlciwgTGlrZUludCk6CiAgICAgICAgICAgICByZXR1cm4gVHJ1ZQogICAgICAgICBlbHNlOgogICAgICAgICAgICAgcmV0dXJuIEZhbHNlCgogICAgZGVmIF9fZ2VfXyhzZWxmLCBvdGhlcik6CiAgICAgICAgIGlmIGlzaW5zdGFuY2Uob3RoZXIsIExpa2VJbnQpOgogICAgICAgICAgICAgcmV0dXJuIFRydWUKICAgICAgICAgZWxzZToKICAgICAgICAgICAgICByZXR1cm4gTm90SW1wbGVtZW50ZWQKCmEgPSBMaWtlRGF0ZSgpCmIgPSBMaWtlSW50KCkKcHJpbnQoYSA9PSBiKSAjIEZhbHNlCnByaW50KGEgPT0gMCkgIyBGYWxzZSwgYmVjYXVzZSBpbnQgcHJvdmlkZXMgYW4gX19lcV9fIG1ldGhvZCB0aGF0IHJldHVybnMgRmFsc2UKcHJpbnQoYSA+PSAwKSAjIEVycm9yLCBiZWNhdXNlIG5ldGhlciBMaWtlRGF0ZSBub3IgaW50IHByb3ZpZGVzIGEgZGVmaW5pdGUgY29tcGFyaXNvbiBmb3IgX19nZV9fCnByaW50KGEgPj0gYikgIyBFcnJvciwgYmVjYXVzZSBuZWl0aGVyIG9iamVjdHMgcHJvdmlkZSBhIGNvbXBhcmFibGUgX19nZV9f