Skip to content

Commit 1161111

Browse files
committed
gh-106318: Add more useful examples for str.casefold()
1 parent 17bf91d commit 1161111

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Doc/library/stdtypes.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,14 +1841,16 @@ expression support in the :mod:`re` module).
18411841
intended to remove all case distinctions in a string. For example, the German
18421842
lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already
18431843
lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold`
1844-
converts it to ``"ss"``, as follows:
1844+
converts it to ``"ss"``. This is useful for case-insensitive string comparisons.
1845+
For example:
18451846

18461847
.. doctest::
18471848

1848-
>>> 'ß'.casefold()
1849-
'ss'
1850-
>>> 'ß'.lower()
1851-
'ß'
1849+
>>> 'straße'.lower() == 'strasse'
1850+
False
1851+
>>> 'straße'.casefold() == 'strasse'
1852+
True
1853+
18521854

18531855
The casefolding algorithm is `described in section 3.13.3 'Default Case
18541856
Folding' of the Unicode Standard

0 commit comments

Comments
 (0)