summaryrefslogtreecommitdiffstats
path: root/Lib/collections
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-02-26 06:53:58 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-02-26 06:53:58 (GMT)
commitd032131dcbb781b25756067653185067cbaf983d (patch)
treea78236ef99abf634ceda60c2dd5fa88da523c876 /Lib/collections
parentcb8b94447c2987c97c5bffbf550da882bdcde9f9 (diff)
downloadcpython-d032131dcbb781b25756067653185067cbaf983d.zip
cpython-d032131dcbb781b25756067653185067cbaf983d.tar.gz
cpython-d032131dcbb781b25756067653185067cbaf983d.tar.bz2
Add __bool__ method. Add tests. Fix-up broken test.
Diffstat (limited to 'Lib/collections')
-rw-r--r--Lib/collections/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index aab5aee..922bba2 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -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(