dict diff

Steve Holden steve at holdenweb.com
Sat Nov 20 07:11:53 CET 2010

On 11/19/2010 8:58 PM, Jin Yi wrote:
> so i came up with a diff method to compare 2 dicts.  i found it pretty
> useful so i thought i'd share it with everyone.  you can see the doctest
> to check out suggested uses.  since we can't modify built-ins, i
> demonstrated adding a diff method to OrderedDict to show how one could
> add it to your own mapping objects.
> the core logic is compatible with python2 and 3 (i've only tested using
> 2.6.5 and 3.1.2).  the doctest is suited for python3 though.
> the interface is pretty straightforward.  it would be awesome to have
> this sucker as a method on the builtin dict, but that'd take a pep, no?
A PEP *and* some explanation of why you would want such an obscure piece
of code built in to the dict object, yes.

Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17       http://us.pycon.org/
See Python Video!       http://python.mirocommunity.org/
Holden Web LLC                 http://www.holdenweb.com/

More information about the Python-list mailing list