Project

General

Profile

1 2359 aaronmk
# Objects
2
3 2362 aaronmk
import util
4
5 2359 aaronmk
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 2362 aaronmk
12
    def __eq__(self, other):
13
        return (other != None and other.__class__ == self.__class__
14 2700 aaronmk
            and other._compare_on() == self._compare_on())
15 2362 aaronmk
16 2700 aaronmk
    def __hash__(self): return hash(tuple(self._compare_on().iteritems()))
17
18
    def _compare_on(self): return self.__dict__