python – How do I merge two dictionaries in a single expression?
How can I merge two Python dictionaries in a single expression? For dictionaries x and ytheir shallowly-merged dictionary z takes values from yreplacing those from x. In Python 3.9.0 or greater (released 17 October 2020, PEP-584discussed here): z = x | y In Python 3.5 or greater: z = {**x, **y} In Python 2, (or … Read more