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.
This commit is contained in:
Fred Drake 2001-05-02 20:20:53 +00:00
parent eacdec6b38
commit 72987a4b96
1 changed files with 9 additions and 0 deletions

View File

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