Posts: 4,580
Threads: 1,472
Joined: Sep 2016
i have a dictionary of dictionaries. and i have another one to update the first one with on an individual item-by-item basis. it appears that dictodicts1.update(dictodicts2) is not really going to to this right. i suspect that for a subdictionary that is in both (has the same key in both dictodicts1 and dictodicts2), doing an update like that will replace one whole subdictionary with another whole subdictionary. bet i could be wrong about that. if i am right, does anyone know a good way to update the 1st from the 2nd on an individual item-by-item basis?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,580
Threads: 1,472
Joined: Sep 2016
i want to add whatever is not already there and replace whatever is there that the update object has, whether that is in the first level or second. if there is a case of more than one value in different dictionaries at the 2nd level but in the same dictionary at the first level, the result should be a combined entry. so the logic should work with leaf entries.
there is a situation that is going to be hard to deal with and that is where one source has a dictionary with one or more objects at any level conflicting with a non-dictionary object, which will force a decision to replace one or the other, with implications at the level below.
i'm wondering if flattening this to a list (could help) of key,reference 2-tuples where each key is an N-tuple based on how many levels down it is.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.