MRAB writes: > On 2016-09-27 08:32, Jussi Piitulainen wrote: > [snip] > >> Is ChainMap really that bad? Otherwise the following would look somewhat >> nice: >> >> d = dict(ChainMap(d1, d2, d3).items()) >> >> Those come to mind. >> > You can copy a dict just by passing it to 'dict': > > d = dict(d1) > > so I wondered if you can do the same with ChainMap: > > d = dict(ChainMap(d1, d2, d3)) > > Yep, you can!
I wasn't sure if it makes a copy or just returns the dict. But it's true: help(dict) says dict(mapping) is a "new dictionary initialized from a mapping object's (key, value) pairs". -- https://mail.python.org/mailman/listinfo/python-list