Skip to content

Instantly share code, notes, and snippets.

@ashiato45
Created March 29, 2019 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashiato45/da31ede2c77f128cb83cb9a79d6e82c3 to your computer and use it in GitHub Desktop.
Save ashiato45/da31ede2c77f128cb83cb9a79d6e82c3 to your computer and use it in GitHub Desktop.
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