class CA(object):

    def __init__(self, name):
        self.name = name

def _key(self):
    return type(self), self.name

def __hash__(self):
    return hash(self._key())

def __eq__(self, other):
    if self._key() == other._key():
        return True
return False

def __ne__(self, other):
    return not self.__eq__(other)
Unexpected behavior for python set.__contains__