Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A:
- def __init__(self, a, b):
- self.a = a
- self.b = b
- def __repr__(self):
- return "["+str(self.a)+","+str(self.b)+"]"
- def __eq__(self, oth):
- if self.a == oth.a and self.b == oth.b:
- return False
- return True
- def __ne__(self,oth):
- return not self == oth
- def __hash__(self):
- return self.a*1000+self.b
- a = set()
- a.add(A(1,2))
- a.add(A(2,2))
- a.add(A(1,2))
- for i in a:
- print i,hash(i)
- print a
Add Comment
Please, Sign In to add comment