[issue16613] ChainMap.new_child could use improvement

Vinay Sajip report at bugs.python.org
Wed Dec 5 10:13:11 CET 2012


New submission from Vinay Sajip:

ChainMap.new_child could IMO be improved through allowing an optional dict to be passed, which is used to create the child. The use case is that you sometimes need to temporarily push a new non-empty mapping in front of an existing chain. This could be achieved by changing new_child to the following, which is backwards-compatible:

    def new_child(self, d=None):
        'New ChainMap with a new dict followed by all previous maps.'
        return self.__class__(d or {}, *self.maps)

----------
components: Library (Lib)
messages: 176974
nosy: rhettinger, vinay.sajip
priority: normal
severity: normal
status: open
title: ChainMap.new_child could use improvement
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16613>
_______________________________________


More information about the Python-bugs-list mailing list