mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788)
This commit is contained in:
parent
9c376bc1c4
commit
9923df9641
4 changed files with 18 additions and 6 deletions
|
@ -1010,12 +1010,15 @@ class ChainMap(_collections_abc.MutableMapping):
|
|||
|
||||
__copy__ = copy
|
||||
|
||||
def new_child(self, m=None): # like Django's Context.push()
|
||||
def new_child(self, m=None, **kwargs): # like Django's Context.push()
|
||||
'''New ChainMap with a new map followed by all previous maps.
|
||||
If no map is provided, an empty dict is used.
|
||||
Keyword arguments update the map or new empty dict.
|
||||
'''
|
||||
if m is None:
|
||||
m = {}
|
||||
m = kwargs
|
||||
elif kwargs:
|
||||
m.update(kwargs)
|
||||
return self.__class__(m, *self.maps)
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue