forked from ungleich-public/cdist
implement __lt__ and __eq__ to support sorting a list of types
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
7b9ff27356
commit
bf1b995908
1 changed files with 6 additions and 0 deletions
|
@ -86,6 +86,12 @@ class Type(object):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Type %s>' % self.name
|
return '<Type %s>' % self.name
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return isinstance(other, self.__class__) and self.name == other.name
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
return isinstance(other, self.__class__) and self.name < other.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_singleton(self):
|
def is_singleton(self):
|
||||||
"""Check whether a type is a singleton."""
|
"""Check whether a type is a singleton."""
|
||||||
|
|
Loading…
Reference in a new issue