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

View file

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