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

Skip to content

Commit cbd2ab1

Browse files
committed
#1513299: cleanup some map() uses where a comprehension works better.
1 parent 8334fd9 commit cbd2ab1

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

Lib/http/cookies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _quote(str, LegalChars=_LegalChars):
230230
if all(c in LegalChars for c in str):
231231
return str
232232
else:
233-
return '"' + _nulljoin(map(_Translator.get, str, str)) + '"'
233+
return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
234234

235235

236236
_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")

Lib/http/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ def nobody_uid():
868868
try:
869869
nobody = pwd.getpwnam('nobody')[2]
870870
except KeyError:
871-
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
871+
nobody = 1 + max(x[2] for x in pwd.getpwall())
872872
return nobody
873873

874874

Lib/pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class TextDoc(Doc):
10001000

10011001
def bold(self, text):
10021002
"""Format a string in bold by overstriking."""
1003-
return ''.join(map(lambda ch: ch + '\b' + ch, text))
1003+
return ''.join(ch + '\b' + ch for ch in text)
10041004

10051005
def indent(self, text, prefix=' '):
10061006
"""Indent text by prepending a given prefix to each line."""
@@ -1024,7 +1024,7 @@ def formattree(self, tree, modname, parent=None, prefix=''):
10241024
c, bases = entry
10251025
result = result + prefix + classname(c, modname)
10261026
if bases and bases != (parent,):
1027-
parents = map(lambda c, m=modname: classname(c, m), bases)
1027+
parents = (classname(c, modname) for c in bases)
10281028
result = result + '(%s)' % ', '.join(parents)
10291029
result = result + '\n'
10301030
elif type(entry) is type([]):

Lib/tabnanny.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def not_less_witness(self, other):
264264
return a
265265

266266
def format_witnesses(w):
267-
firsts = map(lambda tup: str(tup[0]), w)
267+
firsts = (str(tup[0]) for tup in w)
268268
prefix = "at tab size"
269269
if len(w) > 1:
270270
prefix = prefix + "s"

Lib/test/pystone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def pystones(loops=LOOPS):
7272
Char1Glob = '\0'
7373
Char2Glob = '\0'
7474
Array1Glob = [0]*51
75-
Array2Glob = list(map(lambda x: x[:], [Array1Glob]*51))
75+
Array2Glob = [x[:] for x in [Array1Glob]*51]
7676
PtrGlb = None
7777
PtrGlbNext = None
7878

Lib/test/test_long.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def slow_format(self, x, base):
276276
digits = digits or [0]
277277
return '-'[:sign] + \
278278
{2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
279-
"".join(map(lambda i: "0123456789abcdef"[i], digits))
279+
"".join("0123456789abcdef"[i] for i in digits)
280280

281281
def check_format_1(self, x):
282282
for base, mapper in (8, oct), (10, repr), (16, hex):

0 commit comments

Comments
 (0)