[Python-checkins] python/dist/src/Lib sets.py,1.21,1.22
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 25 Aug 2002 11:43:12 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv26090/lib
Modified Files:
sets.py
Log Message:
Implemented <, <=, >, >= for sets, giving subset and proper-subset
meanings. I did not add new, e.g., ispropersubset() methods; we're
going nuts on those, and, e.g., there was no "friendly name" for
== either.
Index: sets.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sets.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** sets.py 25 Aug 2002 17:10:17 -0000 1.21
--- sets.py 25 Aug 2002 18:43:10 -0000 1.22
***************
*** 276,279 ****
--- 276,291 ----
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