This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add keyword argument support to ChainMap.new_child()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: kamilturek, rhettinger
Priority: normal Keywords: patch

Created on 2021-02-17 19:48 by rhettinger, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24788 merged kamilturek, 2021-03-08 22:06
Messages (2)
msg387186 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-02-17 19:48
This would it more convenient to extend chains for local contexts.  Currently, we write:

    local = parent.new_child(dict(foreground='white', background='cyan'))

Instead, it would be easier to write:

    local = parent.new_child(foreground='white', background='cyan')

The new code would look like this:

    def new_child(self, m=None, **kwargs):
        '''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 = kwargs
        elif kwargs:
            m.update(kwargs)
        return self.__class__(m, *self.maps)
msg388652 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-03-14 03:15
New changeset 9923df96413a0b480a34ec1d537b66ca0eeb0fdc by Kamil Turek in branch 'master':
bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788)
https://github.com/python/cpython/commit/9923df96413a0b480a34ec1d537b66ca0eeb0fdc
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87411
2021-03-14 03:16:08rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-03-14 03:15:50rhettingersetmessages: + msg388652
2021-03-08 22:06:50kamiltureksetkeywords: + patch
stage: patch review
pull_requests: + pull_request23554
2021-03-06 18:04:44kamiltureksetnosy: + kamilturek
2021-02-17 19:48:44rhettingercreate