1. Home
  2. Docs
  3. OOP
  4. eq(self, other)

eq(self, other)

__eq__(self, other) মেথডটি দুটি অবজেক্ট সমান কিনা তা পরীক্ষা করতে ব্যবহৃত হয়।

উদাহরণ:

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

point1 = Point(10, 20)
point2 = Point(10, 20)

print(point1 == point2)
# Output: True

How can we help?