summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspeedrun-program <71526906+speedrun-program@users.noreply.github.com>2021-09-16 12:49:38 -0700
committerGitHub <noreply@github.com>2021-09-16 14:49:38 -0500
commita59ede244714455aa9ee8637608e019a20fa2ca6 (patch)
tree4fa0f743ec7e6e0c9d140002e28d0ca9d209c7cb
parentf4b94b1f57827083990272b5f282aa1493ae2bf4 (diff)
downloadcpython-git-a59ede244714455aa9ee8637608e019a20fa2ca6.tar.gz
bpo-45225: use map function instead of genexpr in capwords (GH-28342)
-rw-r--r--Lib/string.py2
-rw-r--r--Misc/NEWS.d/next/Library/2021-09-16-19-02-14.bpo-45225.xmKV4i.rst1
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 489777b10c..261789cc10 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -45,7 +45,7 @@ def capwords(s, sep=None):
sep is used to split and join the words.
"""
- return (sep or ' ').join(x.capitalize() for x in s.split(sep))
+ return (sep or ' ').join(map(str.capitalize, s.split(sep)))
####################################################################
diff --git a/Misc/NEWS.d/next/Library/2021-09-16-19-02-14.bpo-45225.xmKV4i.rst b/Misc/NEWS.d/next/Library/2021-09-16-19-02-14.bpo-45225.xmKV4i.rst
new file mode 100644
index 0000000000..734fdd9b00
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-09-16-19-02-14.bpo-45225.xmKV4i.rst
@@ -0,0 +1 @@
+use map function instead of genexpr in capwords. \ No newline at end of file