May-27-2024, 03:30 PM
(This post was last modified: May-27-2024, 03:30 PM by wardancer84.)
(May-27-2024, 02:57 PM)deanhystad Wrote: If a = {X:[y, z]} and b = {Y:[y, z]} are there any duplicates, or do the keys have to match to be a duplicate?
Is X a duplicate in this: a = {X:[]}, b = {X:[]}
Is y a duplicate in this: a = {X:[y]}, b={X:[[y]]}
"Duplicate" is very vague. Maybe it is clear to you since you defined what it means in your head, but you haven't shared that definition here.
If a = {X:[y, z]} and b = {Y:[y, z]} are there any duplicates, or do the keys have to match to be a duplicate?
as stated in posting #3 only the values matters
Is X a duplicate in this: a = {X:[]}, b = {X:[]}No
Is y a duplicate in this: a = {X:[y]}, b={X:[[y]]}No
Is y a duplicate in this: a = {X:['y', '1']}, b={X:['y', '0']}Yes
i use this function to get the CHANGED values between two dicts, this works perfectly well...
# return a dict with all the changed values def get_changed(a, b): filtered_dict = {} for key in a: try: a.get(key) != b[key] except KeyError: continue filtered_dict[key] = [value for value in b[key] if value not in a.get(key, [])] return filtered_dictbut this function that looksup the DELETED values returns wrong data, changed values are somehow returned as deleted values in addition to the actual deleted values, maybe i should only iterate the keys...no idea...
# return a dict that contains what is missing in current data def get_deleted(a, b): answer = {} for key, value in a.items(): try: v = b[key] except KeyError: continue ls_del = [i for i in value if i not in v] answer[key] = {} #answer[key] = ls_del or [None] answer[key] = ls_del print("get_delete_func", answer) return answer