diff options
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index ff0ace0..3897fb9 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -275,6 +275,18 @@ class BaseSet(object): return False return True + # Inequality comparisons using the is-subset relation. + __le__ = issubset + __ge__ = issuperset + + def __lt__(self, other): + self._binary_sanity_check(other) + return len(self) < len(other) and self.issubset(other) + + def __gt__(self, other): + self._binary_sanity_check(other) + return len(self) > len(other) and self.issuperset(other) + # Assorted helpers def _binary_sanity_check(self, other): |