How do I merge two dictionaries in a single expression (taking union of dictionaries)?
How can I merge two Python dictionaries in a single expression? For dictionaries x and y, z becomes a shallowly-merged dictionary with values from y replacing those from x. In Python 3.9.0 or greater (released 17 October 2020): PEP-584, discussed here, was implemented and provides the simplest method: z = x | y # NOTE: … Read more