Fill-in missing Set comparisons

This commit is contained in:
Raymond Hettinger 2008-02-08 23:34:21 +00:00
parent 18a1ffcda3
commit d53f1c4d41
1 changed files with 13 additions and 0 deletions

View File

@ -163,11 +163,24 @@ class Set:
return NotImplemented
return len(self) < len(other) and self.__le__(other)
def __gt__(self, other):
if not isinstance(other, Set):
return NotImplemented
return other < self
def __ge__(self, other):
if not isinstance(other, Set):
return NotImplemented
return other <= self
def __eq__(self, other):
if not isinstance(other, Set):
return NotImplemented
return len(self) == len(other) and self.__le__(other)
def __ne__(self, other):
return not (self == other)
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.