root/lib/objects.py @ 2362
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.__dict__ == self.__dict__) |
15 |
|
16 |
def __hash__(self): return hash(tuple(self.__dict__.iteritems())) |