From 17bf91dfd6f3f80555e3f26338e889fdc7811c02 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 27 Feb 2021 20:27:04 -0300 Subject: [PATCH 1/2] gh-106318: Add examples for str.casefold() and str.lower() methods --- Doc/library/stdtypes.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 8b896011734df5..28129a66ff9431 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1841,7 +1841,14 @@ expression support in the :mod:`re` module). intended to remove all case distinctions in a string. For example, the German lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold` - converts it to ``"ss"``. + converts it to ``"ss"``, as follows: + + .. doctest:: + + >>> 'ß'.casefold() + 'ss' + >>> 'ß'.lower() + 'ß' The casefolding algorithm is `described in section 3.13.3 'Default Case Folding' of the Unicode Standard @@ -2250,7 +2257,12 @@ expression support in the :mod:`re` module). .. method:: str.lower() Return a copy of the string with all the cased characters [4]_ converted to - lowercase. + lowercase. For example: + + .. doctest:: + + >>> 'Lower Method Example'.lower() + 'lower method example' The lowercasing algorithm used is `described in section 3.13.2 'Default Case Conversion' of the Unicode Standard From 116111145a983bee6b64c70183c90b2e68f045ac Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Sat, 13 Dec 2025 18:53:09 +0000 Subject: [PATCH 2/2] gh-106318: Add more useful examples for str.casefold() --- Doc/library/stdtypes.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 28129a66ff9431..1b64f30a518744 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1841,14 +1841,16 @@ expression support in the :mod:`re` module). intended to remove all case distinctions in a string. For example, the German lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold` - converts it to ``"ss"``, as follows: + converts it to ``"ss"``. This is useful for case-insensitive string comparisons. + For example: .. doctest:: - >>> 'ß'.casefold() - 'ss' - >>> 'ß'.lower() - 'ß' + >>> 'straße'.lower() == 'strasse' + False + >>> 'straße'.casefold() == 'strasse' + True + The casefolding algorithm is `described in section 3.13.3 'Default Case Folding' of the Unicode Standard