Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 72987a4

Browse files
committed
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.
1 parent eacdec6 commit 72987a4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/mailbox.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ def __init__(self, fp, factory=rfc822.Message):
1414
self.seekp = 0
1515
self.factory = factory
1616

17+
def __iter__(self):
18+
return self
19+
1720
def next(self):
1821
while 1:
1922
self.fp.seek(self.seekp)
@@ -191,6 +194,9 @@ def __init__(self, dirname, factory=rfc822.Message):
191194
self.boxes = map(str, list)
192195
self.factory = factory
193196

197+
def __iter__(self):
198+
return self
199+
194200
def next(self):
195201
if not self.boxes:
196202
return None
@@ -219,6 +225,9 @@ def __init__(self, dirname, factory=rfc822.Message):
219225

220226
self.boxes = boxes
221227

228+
def __iter__(self):
229+
return self
230+
222231
def next(self):
223232
if not self.boxes:
224233
return None

0 commit comments

Comments
 (0)