From ff1c12a4d4baff2381e13ada80b61eee77c8f3f5 Mon Sep 17 00:00:00 2001 From: Cameron Beck <94604154+cbkinase@users.noreply.github.com> Date: Sat, 18 Oct 2025 21:50:04 -0400 Subject: [PATCH] Correct Glossary key function example to use str.casefold instead of str.lower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The glossary currently states: “the str.lower() method can serve as a key function for case-insensitive sorts.” I believe this should be updated to use str.casefold() instead. str.casefold() is recommended for case-insensitive matching in Unicode, and it provides more accurate behavior across languages than str.lower(). This also aligns with the "Sorting Techniques" section of the docs, which uses str.casefold() as the key function for case-insensitive sorting. --- Doc/glossary.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/glossary.rst b/Doc/glossary.rst index c0ca0be304ebe4..04b3a6bf5c8465 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -813,7 +813,7 @@ Glossary :func:`itertools.groupby`. There are several ways to create a key function. For example. the - :meth:`str.lower` method can serve as a key function for case insensitive + :meth:`str.casefold` method can serve as a key function for case insensitive sorts. Alternatively, a key function can be built from a :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, :func:`operator.attrgetter`, :func:`operator.itemgetter`, and