Aaron Hall <aaronch...@yahoo.com> added the comment:
Another obvious way to do it, but I'm +1 on it. A small side point however - PEP 584 reads: > 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[2]. ... > [2] Non-string keys: https://bugs.python.org/issue35105 and > https://mail.python.org/pipermail/python-dev/2018-October/155435.html The references cited does not back this assertion up. Perhaps the intent is to reference the "cool/weird hack" dict(d1, **d2) (see https://mail.python.org/pipermail/python-dev/2010-April/099485.html and https://mail.python.org/pipermail/python-dev/2010-April/099459.html), which allowed any hashable keys in Python 2 but only strings in Python 3. If I see {**d1, **d2}, my expectations are that this is the new generalized unpacking and I currently expect any keys to be allowed, and the PEP should be updated to accurately reflect this to prevent future misunderstandings. ---------- nosy: +Aaron Hall _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36144> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com