Add __bool__ method. Add tests. Fix-up broken test.

This commit is contained in:
Raymond Hettinger 2011-02-26 06:53:58 +00:00
parent cb8b94447c
commit d032131dcb
2 changed files with 17 additions and 8 deletions

View file

@ -679,6 +679,9 @@ class ChainMap(MutableMapping):
def __contains__(self, key):
return any(key in m for m in self.maps)
def __bool__(self):
return any(self.maps)
@_recursive_repr()
def __repr__(self):
return '{0.__class__.__name__}({1})'.format(