def dict_overwrite(base, default={}):
"""Creates a new dictionary overwriting the values from the
default dictionary completing with the base key/values.
"""
# clone current level
new = default.copy()
for key,value in base.items():
if isinstance(value, list):
new[key] = value[:]
elif isinstance(value, dict):
new[key] = dict_override(value, default.get(key, {}))
else:
new[key] = value
return new
评论列表
文章目录