[Python-3000-checkins] r60678 - python/branches/py3k/Lib/_abcoll.py

raymond.hettinger python-3000-checkins at python.org
Sat Feb 9 01:08:17 CET 2008


Author: raymond.hettinger
Date: Sat Feb  9 01:08:16 2008
New Revision: 60678

Modified:
   python/branches/py3k/Lib/_abcoll.py
Log:
Merge r60674 an 60675.



Modified: python/branches/py3k/Lib/_abcoll.py
==============================================================================
--- python/branches/py3k/Lib/_abcoll.py	(original)
+++ python/branches/py3k/Lib/_abcoll.py	Sat Feb  9 01:08:16 2008
@@ -197,11 +197,24 @@
             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.
@@ -528,13 +541,13 @@
 
     def __iter__(self):
         i = 0
-        while True:
-            try:
+        try:
+            while True:
                 v = self[i]
-            except IndexError:
-                break
-            yield v
-            i += 1
+                yield v
+                i += 1
+        except IndexError:
+            return
 
     def __contains__(self, value):
         for v in self:


More information about the Python-3000-checkins mailing list