def ref(self, key): try: hash(key) except TypeError: return self._iddict, Hashable(key) # key is not hashable try: weakref.ref(key) except TypeError: return self._regdict, key # key cannot be weakly ref'ed else: return self._weakdict, key # normal case
def __init__(self, value, concretetype = None): Hashable.__init__(self, value) if concretetype is not None: self.concretetype = concretetype
def __hash__(self): return hash((self.__class__, self.type, Hashable(self.instance)))
def __init__(self, value, concretetype=None): Hashable.__init__(self, value) if concretetype is not None: self.concretetype = concretetype