]> granicus.if.org Git - python/commitdiff
Use built in function filter instead of doing it laboriously by hand.
authorSjoerd Mullender <sjoerd@acm.org>
Fri, 11 Aug 2000 07:48:36 +0000 (07:48 +0000)
committerSjoerd Mullender <sjoerd@acm.org>
Fri, 11 Aug 2000 07:48:36 +0000 (07:48 +0000)
Lib/mailbox.py

index afd9a55760007fd70c901a44cceb74c1dc025eae..4518e7d0629ebe66a6e2a2e3661274816f992c64 100755 (executable)
@@ -157,11 +157,10 @@ class MHMailbox:
         import re
         pat = re.compile('^[1-9][0-9]*$')
         self.dirname = dirname
-        files = os.listdir(self.dirname)
-        list = []
-        for f in files:
-            if pat.match(f):
-                list.append(f)
+        # the three following lines could be combined into:
+        # list = map(long, filter(pat.match, os.listdir(self.dirname)))
+        list = os.listdir(self.dirname)
+        list = filter(pat.match, list)
         list = map(long, list)
         list.sort()
         # This only works in Python 1.6 or later;