Created
May 25, 2016 12:54
-
-
Save jacqueswww/e8116aedf05a3b19355c46265e687f0f to your computer and use it in GitHub Desktop.
One dictionary exists in another
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
def dict_contains(primary, secondary): | |
""" | |
Does primary dict contains all the same items as secondary. | |
""" | |
assert isinstance(primary, dict) | |
assert isinstance(secondary, dict) | |
for key, val in secondary.items(): | |
if key not in primary: | |
return False | |
elif primary[key] != val: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment