Open this example in the interactive library
Source code
defaults = {'theme': 'dark', 'size': 14}
print(defaults | {'size': 16})Sample output
{'theme': 'dark', 'size': 16}
Merge dictionaries. A self-contained example using the Python standard library.
Open this example in the interactive library
defaults = {'theme': 'dark', 'size': 14}
print(defaults | {'size': 16}){'theme': 'dark', 'size': 16}