class SomeClass(object):
someattribute = "somevalue"
def __eq__(self, other):
return self.someattribute == other.someattribute
def __hash__(self):
return hash(self.someattribute)
def __ne__(self, other):
return not self.__eq__(other)
list_of_objects = [SomeClass()]
print(SomeClass() in list_of_objects)
set_of_objects = set([SomeClass()])
print(SomeClass() in set_of_objects)
Y2xhc3MgU29tZUNsYXNzKG9iamVjdCk6CiAgICBzb21lYXR0cmlidXRlID0gInNvbWV2YWx1ZSIKICAgIGRlZiBfX2VxX18oc2VsZiwgb3RoZXIpOgogICAgICAgIHJldHVybiBzZWxmLnNvbWVhdHRyaWJ1dGUgPT0gb3RoZXIuc29tZWF0dHJpYnV0ZQogICAgZGVmIF9faGFzaF9fKHNlbGYpOgogICAgICAgIHJldHVybiBoYXNoKHNlbGYuc29tZWF0dHJpYnV0ZSkKICAgIGRlZiBfX25lX18oc2VsZiwgb3RoZXIpOgogICAgICAgIHJldHVybiBub3Qgc2VsZi5fX2VxX18ob3RoZXIpCgpsaXN0X29mX29iamVjdHMgPSBbU29tZUNsYXNzKCldCnByaW50KFNvbWVDbGFzcygpIGluIGxpc3Rfb2Zfb2JqZWN0cykKCnNldF9vZl9vYmplY3RzID0gc2V0KFtTb21lQ2xhc3MoKV0pCnByaW50KFNvbWVDbGFzcygpIGluIHNldF9vZl9vYmplY3RzKQo=