Revision 2362
Added by Aaron Marcuse-Kubitza over 12 years ago
objects.py | ||
---|---|---|
1 | 1 |
# Objects |
2 | 2 |
|
3 |
import util |
|
4 |
|
|
3 | 5 |
class BasicObject: |
4 | 6 |
'''Provides default implementations of commonly-used methods''' |
5 | 7 |
|
6 | 8 |
def __str__(self): return util.class_name(self)+repr(self.__dict__) |
7 | 9 |
|
8 | 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())) |
Also available in: Unified diff
objects.py: BasicObject: Fixed bug where util needed to be imported. Added eq() and hash().