implement __lt__ to support sorting a list of objects

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-11-01 22:46:46 +01:00
parent bf1b995908
commit 70ee0f1681
1 changed files with 4 additions and 0 deletions

View File

@ -115,6 +115,10 @@ class Object(object):
"""define equality as 'attributes are the same'"""
return self.__dict__ == other.__dict__
def __lt__(self, other):
return isinstance(other, self.__class__) and self.name < other.name
# FIXME: still needed?
@property
def explorer_path(self):