summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-05-02 20:20:53 (GMT)
committerFred Drake <fdrake@acm.org>2001-05-02 20:20:53 (GMT)
commit72987a4b966808fa888394b313eb462cfc34b087 (patch)
tree9d0c371dbd139b8430d320b2ae298790f02ea9c7 /Lib/mailbox.py
parenteacdec6b386d688ea9939472b33bc33ea6310f68 (diff)
downloadcpython-72987a4b966808fa888394b313eb462cfc34b087.zip
cpython-72987a4b966808fa888394b313eb462cfc34b087.tar.gz
cpython-72987a4b966808fa888394b313eb462cfc34b087.tar.bz2
Make the Mailbox objects support iteration -- they already had the
appropriate next() method, and this is what people really want to do with these objects in practice.
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-xLib/mailbox.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 29322ed..2c80a62 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -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