I have a Point class with x and y attributes. I would like to get a False comparison of a Point object with any other type of object. For example, Point(0, 1) == None does not work:
AttributeError: 'NoneType' object has no attribute 'x'
Grade:
class Point(): def __init__(self, x, y): self.x = x self.y = y def __eq__(self, other): return self.x == other.x and self.y == other.y def __ne__(self, other): return not self.__eq__(other)
How do I configure __eq__ to get False compared to any other type of object?
source share