If you have Python> = 3.5 , you can use the keyword extension in dict literal:
>>> d = {'x': '2', 'y': '1'} >>> {**d, 'x':1} {'x': 1, 'y': '1'}
This is sometimes called "splatting."
If you're on Python 2.7, well, there is no equivalent. This is a problem with using something for more than 7 years. You will need to do something like:
>>> d = {'x': '2', 'y': '1'} >>> x = {'x':1} >>> x.update(d) >>> x {'x': '2', 'y': '1'}
source share