mirror of
https://github.com/python/cpython.git
synced 2025-10-11 09:23:31 +00:00
Lists work better when popping from the right.
This commit is contained in:
parent
3ba85c2e8a
commit
b5ba8d749d
1 changed files with 4 additions and 3 deletions
|
@ -199,6 +199,7 @@ class MHMailbox:
|
||||||
# This only works in Python 1.6 or later;
|
# This only works in Python 1.6 or later;
|
||||||
# before that str() added 'L':
|
# before that str() added 'L':
|
||||||
self.boxes = map(str, list)
|
self.boxes = map(str, list)
|
||||||
|
self.boxes.reverse()
|
||||||
self.factory = factory
|
self.factory = factory
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
@ -207,7 +208,7 @@ class MHMailbox:
|
||||||
def next(self):
|
def next(self):
|
||||||
if not self.boxes:
|
if not self.boxes:
|
||||||
return None
|
return None
|
||||||
fn = self.boxes.pop(0)
|
fn = self.boxes.pop()
|
||||||
fp = open(os.path.join(self.dirname, fn))
|
fp = open(os.path.join(self.dirname, fn))
|
||||||
msg = self.factory(fp)
|
msg = self.factory(fp)
|
||||||
try:
|
try:
|
||||||
|
@ -233,7 +234,7 @@ class Maildir:
|
||||||
curdir = os.path.join(self.dirname, 'cur')
|
curdir = os.path.join(self.dirname, 'cur')
|
||||||
boxes += [os.path.join(curdir, f)
|
boxes += [os.path.join(curdir, f)
|
||||||
for f in os.listdir(curdir) if f[0] != '.']
|
for f in os.listdir(curdir) if f[0] != '.']
|
||||||
|
boxes.reverse()
|
||||||
self.boxes = boxes
|
self.boxes = boxes
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
@ -242,7 +243,7 @@ class Maildir:
|
||||||
def next(self):
|
def next(self):
|
||||||
if not self.boxes:
|
if not self.boxes:
|
||||||
return None
|
return None
|
||||||
fn = self.boxes.pop(0)
|
fn = self.boxes.pop()
|
||||||
fp = open(fn)
|
fp = open(fn)
|
||||||
return self.factory(fp)
|
return self.factory(fp)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue