Created
March 29, 2019 04:21
-
-
Save ashiato45/da31ede2c77f128cb83cb9a79d6e82c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C: | |
def __init__(self, x): | |
self.x = x | |
def __eq__(self, y): # crucial! | |
return self.x == y.x | |
def __hash__(self): | |
return hash(self.x) | |
x = set() | |
a = C(2) | |
b = C(2) | |
x.add(a) | |
x.add(b) | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment