Python has the **
operator, which spreads a dictionary within another dictionary or function arguments.
This works well in the example:
default = {'a':5}
a = {'a':15}
{**default, **a}
// => {'a': 15}
However, if one of the value is a dictionary itself, it is overwritten completetly.
default = {'a': {'aa' : 10, 'ab' : 15}}
a = {'a': {'aa': 15}}
{**default, **a}
// => {'a': {'aa': 15}}
// expected => {'a': {'aa' : 15, 'ab' : 15}}
It is overwritten completely. For now I'll make a function that unpacks them recursively, but i was wondering if there is an actual way to do this within python (not necessarily a syntax feature, a standard library function would be OK as well).
If there is no such feature, that is also an acceptable answer.