July 28, 2014
11:04 p.m.
args = dict(...) def f(**kwargs): temp_args = dict(dic0) temp_args.update(kwargs) temp_args.update(dic1) g(**temp_args)
No, you just have to write a one-liner with ChainMap, except in the (very rare) case where you're expecting g to hold onto and later modify its kwargs.
yes, this (modify) is what I do. In any case, it would still be g(**collections.ChainMap(dict1, kwargs, dic0)) In either case a new dict is created and passed to g as kwargs. It's not pretty, but it does work. Thanks. so the general case D = A | B | C becomes D = dict(collections.ChainMap(C, B, A)) (someone may suggest dict could have a "chain" constructor class method D = dict.chain(C, B, A))