Beispiel #1
0
 def __contains__(self, key):
     """
     :return: returns true if key belongs to the association
     :raise: In case the key is not a Node, raises TypeError (see mutable protocol)
     """
     result = _utils.find_assoc(self._ptr, self._key_conv.to_pointer(key))
     return result is not None
Beispiel #2
0
 def __getitem__(self, key):
     """
     :return: retrieves the item corresponding to the given key.
     :raise: In case the key wasn't found in this Assoc, raises KeyError
     ..:warning: key is supposed to be of type Node
     """
     result = _utils.find_assoc(self._ptr, self._key_conv.to_pointer(key))
     if result is not None: 
         return self._val_conv.to_object(result)
     else:
         raise KeyError("Value not found")