mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-07 10:22:27 +08:00
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:
@@ -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
|
||||
# ----------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user