.title() - annoying mistake
Sibylle Koczian
nulla.epistola at web.de
Sat Mar 20 07:53:13 EDT 2021
Am 20.03.2021 um 09:34 schrieb Alan Bawden:
> The real reason Python strings support a .title() method is surely
> because Unicode supports upper, lower, _and_ title case letters, and
> tells you how to map between them. Consider:
>
> >>> '\u01f1'.upper()
> '\u01f1'
>
> This is the "DZ" character.
>
> >>> '\u01f1'.lower()
> '\u01f3'
>
> This is the "dz" character.
>
> >>> '\u01f1'.title()
> '\u01f2'
>
> This is the "Dz" character.
>
> When you write that code to capitalize your book titles, you should be
> calling .title() rather than .upper() if you are doing it right.
>
But that's exactly what he's doing, with a result which is documented,
but not really satisfactory.
More information about the Python-list
mailing list