]> granicus.if.org Git - python/commitdiff
#1513299: cleanup some map() uses where a comprehension works better.
authorGeorg Brandl <georg@python.org>
Sat, 4 Dec 2010 10:39:14 +0000 (10:39 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 4 Dec 2010 10:39:14 +0000 (10:39 +0000)
Lib/http/cookies.py
Lib/http/server.py
Lib/pydoc.py
Lib/tabnanny.py
Lib/test/pystone.py
Lib/test/test_long.py

index 9e51b6791ca16489bc1f9318806b47177290ec08..fb9589c6aa7deb7176dfbc1eab7831f5307a7c54 100644 (file)
@@ -230,7 +230,7 @@ def _quote(str, LegalChars=_LegalChars):
     if all(c in LegalChars for c in str):
         return str
     else:
-        return '"' + _nulljoin(map(_Translator.get, str, str)) + '"'
+        return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
 
 
 _OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")
index 5ebfd25ecece47003408c254282e041f1d42f44b..214071084bc41faa9431fab2f286d7df6b307466 100644 (file)
@@ -868,7 +868,7 @@ def nobody_uid():
     try:
         nobody = pwd.getpwnam('nobody')[2]
     except KeyError:
-        nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
+        nobody = 1 + max(x[2] for x in pwd.getpwall())
     return nobody
 
 
index da3702dedbbfecc6aa48d79d9569a4ac70568e40..ea282f77acdd1e87cc224e28ae1849d482024f5b 100755 (executable)
@@ -1000,7 +1000,7 @@ class TextDoc(Doc):
 
     def bold(self, text):
         """Format a string in bold by overstriking."""
-        return ''.join(map(lambda ch: ch + '\b' + ch, text))
+        return ''.join(ch + '\b' + ch for ch in text)
 
     def indent(self, text, prefix='    '):
         """Indent text by prepending a given prefix to each line."""
@@ -1024,7 +1024,7 @@ class TextDoc(Doc):
                 c, bases = entry
                 result = result + prefix + classname(c, modname)
                 if bases and bases != (parent,):
-                    parents = map(lambda c, m=modname: classname(c, m), bases)
+                    parents = (classname(c, modname) for c in bases)
                     result = result + '(%s)' % ', '.join(parents)
                 result = result + '\n'
             elif type(entry) is type([]):
index a4d4ef0da097540b7820df845cd54129575b15b6..46f8163e5f7e013151b095824ed049fe6e0c2058 100755 (executable)
@@ -264,7 +264,7 @@ class Whitespace:
         return a
 
 def format_witnesses(w):
-    firsts = map(lambda tup: str(tup[0]), w)
+    firsts = (str(tup[0]) for tup in w)
     prefix = "at tab size"
     if len(w) > 1:
         prefix = prefix + "s"
index aad4d8c8f3609819a56451523a4b35b84c5f5010..d7f1ec9b6cc736fe7c51c32580d3e86872d60e81 100755 (executable)
@@ -72,7 +72,7 @@ BoolGlob = FALSE
 Char1Glob = '\0'
 Char2Glob = '\0'
 Array1Glob = [0]*51
-Array2Glob = list(map(lambda x: x[:], [Array1Glob]*51))
+Array2Glob = [x[:] for x in [Array1Glob]*51]
 PtrGlb = None
 PtrGlbNext = None
 
index 133702ec5f2e17188408522bf07a213addfa1195..12197ee638f363c16f8b18a4f5061aebbd3b5b8d 100644 (file)
@@ -276,7 +276,7 @@ class LongTest(unittest.TestCase):
         digits = digits or [0]
         return '-'[:sign] + \
                {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
-               "".join(map(lambda i: "0123456789abcdef"[i], digits))
+               "".join("0123456789abcdef"[i] for i in digits)
 
     def check_format_1(self, x):
         for base, mapper in (8, oct), (10, repr), (16, hex):