2 ms·
From https://www.python.org/dev/peps/pep-0584/#current-alternatives https://www.python.org/dev/peps/pep-0584/#current-alternativ... > To create a new dict cont
by js2 8y ago
From https://www.python.org/dev/peps/pep-0584/#current-alternatives https://www.python.org/dev/peps/pep-0584/#current-alternativ...
> To create a new dict containing the merged items of two (or more) dicts, one can currently write:
{**d1, **d2}
> but this is neither obvious nor easily discoverable. It is only guaranteed to work if the keys are all strings. If the keys are not strings, it currently works in CPython, but it may not work with other implementations, or future versions of CPython.
> It is also limited to returning a built-in dict, not a subclass, unless re-written as MyDict(d1, d2), in which case non-string keys will raise TypeError.