Created
January 28, 2022 13:07
-
-
Save ephes/e35a09c3bd599db4df0c576338ac14b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spam = {"ham": "eggs", "sausage": "tomato"} | |
spam = spam | {"ham": "bacon"} # since 3.9 | |
spam = {**spam, "ham": "bacon"} # since 3.5 | |
spam = dict(spam, ham="bacon") # even on python2 | |
assert spam == {'ham': 'bacon', 'sausage': 'tomato'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment