Project

General

Profile

1
# Objects
2

    
3
import util
4

    
5
class BasicObject:
6
    '''Provides default implementations of commonly-used methods'''
7
    
8
    def __str__(self): return util.class_name(self)+repr(self.__dict__)
9
    
10
    def __repr__(self): return str(self)
11
    
12
    def __eq__(self, other):
13
        return (other != None and other.__class__ == self.__class__
14
            and other._compare_on() == self._compare_on())
15
    
16
    def __hash__(self): return hash(tuple(self._compare_on().iteritems()))
17
    
18
    def _compare_on(self): return self.__dict__
(22-22/40)