Last active
March 18, 2022 18:51
-
-
Save osantana/7000a3bdcdd5142d451b5f1503a04de4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
>>> d1 = d2 = { | |
'name': 'Osvaldo', | |
'address': { | |
'street': 'Rua Goiania', | |
'number': '1597', | |
'complement': 'sob 34' | |
} | |
} | |
>>> patch = { | |
'id': 'deadbeef00', | |
'address': { | |
'id': 'deadbeef01', | |
'complement': 'sobrado 34', | |
'zipcode': '82940150', | |
}, | |
} | |
>>> d1.update(patch) | |
>>> d1 | |
{ | |
'id': 'deadbeef00', | |
'address': { | |
'id': 'deadbeef01', | |
'complement': 'sobrado 34', | |
'zipcode': '82940150', | |
}, | |
} | |
>>> d2.merge(patch) | |
>>> d2 | |
{ | |
'id': 'deadbeef00', | |
'name': 'Osvaldo', | |
'address': { | |
'id': 'deadbeef01', | |
'street': 'Rua Goiania', | |
'number': '1597', | |
'complement': 'sobrado 34' | |
'zipcode': '82940150', | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment