We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7e894c2 commit cd4cfa6Copy full SHA for cd4cfa6
Lib/collections/__init__.py
@@ -1016,7 +1016,7 @@ def __getitem__(self, key):
1016
return self.__missing__(key) # support subclasses that define __missing__
1017
1018
def get(self, key, default=None):
1019
- return self[key] if key in self else default
+ return self[key] if key in self else default # needs to make use of __contains__
1020
1021
def __len__(self):
1022
return len(set().union(*self.maps)) # reuses stored hash values if possible
@@ -1028,7 +1028,10 @@ def __iter__(self):
1028
return iter(d)
1029
1030
def __contains__(self, key):
1031
- return any(key in m for m in self.maps)
+ for mapping in self.maps:
1032
+ if key in mapping:
1033
+ return True
1034
+ return False
1035
1036
def __bool__(self):
1037
return any(self.maps)
0 commit comments