Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InspectorDuck:
- c = 0
- def __init__(self, val):
- self.val = val
- def __eq__(self, other):
- self.c += 1
- print(f"Calling __eq__ on {self}, it is {self.c} time we are doing this")
- return True # change this to "return False" to stop the world from burning
- def __str__(self):
- return str(self.val)
- a = [InspectorDuck(5)]
- b = [InspectorDuck(4)]
- a.append(b)
- b.append(a)
- print(a == b)
Advertisement
Add Comment
Please, Sign In to add comment