Project

General

Profile

1
# Objects
2

    
3
import strings
4
import util
5

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