Created
August 6, 2021 10:51
-
-
Save TAM360/462459340f1f6a8ed27e4ec8f5f43f14 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
def compareObjs(obj_1, obj_2): | |
if (type(obj_1) == dict and type(obj_2) == dict): | |
if len(obj_1) == len(obj_2): | |
for key in obj_1: | |
if key in obj_2 and obj_1[key] == obj_2[key]: | |
return compareObjs(obj_1[key], obj_2[key]) | |
else: | |
return False | |
else: | |
return False | |
else: | |
if ((type(obj_1) == list and type(obj_2) == list) or (type(obj_1) == tuple and type(obj_2) == tuple)): | |
if len(obj_1) == len(obj_2): | |
kv_1 = {} | |
kv_2 = {} | |
for elm in obj_1: | |
if elm in kv_1: | |
kv_1[elm] += 1 | |
else: | |
kv_1[elm] = 1 | |
for elm in obj_2: | |
if elm in kv_2: | |
kv_2[elm] += 1 | |
else: | |
kv_2[elm] = 1 | |
return compareObjs(kv_1, kv_2) | |
else: | |
return False | |
else: | |
return obj_1 == obj_2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment