dictdiffer
dictdiffer copied to clipboard
Generate new dict from diff - dict of changes
Maybe I've missed something but I cant see how to generate a diff dict.
I need a dict representation of the changes to simplify database updates. Is this possible?
diff returns a generator. In your use case it sounds like you need to "instantiate" the diff with list, and if you need a dict, you need to wrap the result explicitly. So something like this?
diff_dict = {"changes": list(diff(a, b))}