On 7/25/2010 8:03 AM, targetsmart wrote:
Hi,
I am trying to compare two nested dictionaries, I want to know what is
the exact difference between them.


d1 = {'a' : 1, 'b' : 2, 'c': 3 }
d2 = {'a' : 1, 'b' : 3, 'd': 4 }

diff = dict(set(d1.items()) - set(d2.items()))

print (diff)

    {'c': 3, 'b': 2}

That's the true "difference", with all entries in d1 not
identically in d2 listed.  Is that what you wanted?

                                        John Nagle

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to