added a __contains__ method that looks for a special property _ndict_contains__ (must be a function)

when present, the in operator behavior will be determined by the return of the special property.
This commit is contained in:
fawce
2012-10-16 12:59:22 -04:00
parent 16aa63ac6e
commit c008a957df
+8
View File
@@ -96,6 +96,14 @@ class ndict(MutableMapping):
def __len__(self):
return len(self.__internal)
#TODO: Eddie please help!
def __contains__(self, key):
if hasattr(self, '_ndict_contains__'):
return self._ndict_contains__(key)
else:
return self.__internal.__contains__(key)
# Compatability with namedicts
# ----------------------------