]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45225: use map function instead of genexpr in capwords (GH-28342)
authorspeedrun-program <71526906+speedrun-program@users.noreply.github.com>
Thu, 16 Sep 2021 19:49:38 +0000 (12:49 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Sep 2021 19:49:38 +0000 (14:49 -0500)
Lib/string.py
Misc/NEWS.d/next/Library/2021-09-16-19-02-14.bpo-45225.xmKV4i.rst [new file with mode: 0644]

index 489777b10c25df7ea1c53444f0df800022af56b4..261789cc10a44c8b71f98ac1db63d26db2435b67 100644 (file)
@@ -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 (file)
index 0000000..734fdd9
--- /dev/null
@@ -0,0 +1 @@
+use map function instead of genexpr in capwords.
\ No newline at end of file