]> granicus.if.org Git - python/commitdiff
Make the Mailbox objects support iteration -- they already had the
authorFred Drake <fdrake@acm.org>
Wed, 2 May 2001 20:20:53 +0000 (20:20 +0000)
committerFred Drake <fdrake@acm.org>
Wed, 2 May 2001 20:20:53 +0000 (20:20 +0000)
appropriate next() method, and this is what people really want to do with
these objects in practice.

Lib/mailbox.py

index 29322ed16be47732879cbd615aa57fcf7c0839b6..2c80a625e1ea55a01076ed1c1b716b56714fee3d 100755 (executable)
@@ -14,6 +14,9 @@ class _Mailbox:
         self.seekp = 0
         self.factory = factory
 
+    def __iter__(self):
+        return self
+
     def next(self):
         while 1:
             self.fp.seek(self.seekp)
@@ -191,6 +194,9 @@ class MHMailbox:
         self.boxes = map(str, list)
         self.factory = factory
 
+    def __iter__(self):
+        return self
+
     def next(self):
         if not self.boxes:
             return None
@@ -219,6 +225,9 @@ class Maildir:
 
         self.boxes = boxes
 
+    def __iter__(self):
+        return self
+
     def next(self):
         if not self.boxes:
             return None