[Python-Dev] PEP 372 -- Adding an ordered directory tocollectionsready for pronouncement

Raymond Hettinger python at rcn.com
Mon Mar 2 21:07:59 CET 2009


Compromise?

     def __eq__(self, other):
        if isinstance(other, OrderedDict):
            return all(map(operator.eq, self.items(), other.items()))
        if isinstance(other, Mapping):
            return dict.__eq__(self, other)
        return NotImplemented # Give other a chance; defaults to False

OrderedDict-to-OrderedDict comparisons are order sensitive -- matching your intuition
OrderedDict-to-OtherMappings -- allow me and Armin to have our substitutability for dicts.


Raymond


More information about the Python-Dev mailing list