Project

General

Profile

« Previous | Next » 

Revision 2700

objects.py: BasicObject: Allow subclasses to customize which attrs are compared on, by adding _compare_on() method

View differences:

lib/objects.py
11 11
    
12 12
    def __eq__(self, other):
13 13
        return (other != None and other.__class__ == self.__class__
14
            and other.__dict__ == self.__dict__)
14
            and other._compare_on() == self._compare_on())
15 15
    
16
    def __hash__(self): return hash(tuple(self.__dict__.iteritems()))
16
    def __hash__(self): return hash(tuple(self._compare_on().iteritems()))
17
    
18
    def _compare_on(self): return self.__dict__

Also available in: Unified diff