summaryrefslogtreecommitdiffstats
path: root/Lib/collections.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-02-23 08:28:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-02-23 08:28:06 (GMT)
commitdcb29c93d23112eef7f37b284a04db5f4b223787 (patch)
tree792d2db9729477fdcf7fd1dd1b8df20daef8f018 /Lib/collections.py
parent48e5cd3df387209d29a8caae0c7a45e1cbbdbc62 (diff)
downloadcpython-dcb29c93d23112eef7f37b284a04db5f4b223787.zip
cpython-dcb29c93d23112eef7f37b284a04db5f4b223787.tar.gz
cpython-dcb29c93d23112eef7f37b284a04db5f4b223787.tar.bz2
Add tests for the collections helper class and sync-up with py3k branch.
Diffstat (limited to 'Lib/collections.py')
-rw-r--r--Lib/collections.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/collections.py b/Lib/collections.py
index 2f19459..98c4325 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -694,6 +694,15 @@ class _ChainMap(MutableMapping):
__copy__ = copy
+ def new_child(self): # like Django's Context.push()
+ 'New ChainMap with a new dict followed by all previous maps.'
+ return self.__class__({}, *self.maps)
+
+ @property
+ def parents(self): # like Django's Context.pop()
+ 'New ChainMap from maps[1:].'
+ return self.__class__(*self.maps[1:])
+
def __setitem__(self, key, value):
self.maps[0][key] = value