blob: 06b55cde41257e9c1be857789726c0efb94cacb3 [file] [log] [blame]
Michal Kobus14e835b2019-04-11 14:25:27 +02001from collections import OrderedDict
2
3
4def merge_dicts_ordered(*dict_args, **extra_entries):
5 """
6 Given an arbitrary number of dictionaries, merge them into a
7 single new dictionary. Later dictionaries take precedence if
8 a key is shared by multiple dictionaries.
9
10 Extra entries can also be provided via kwargs. These entries
11 have the highest precedence.
12 """
13 res = OrderedDict()
14
15 for d in dict_args + (extra_entries,):
16 res.update(d)
17
18 return res