.title() - annoying mistake
David KolovratnÃk
david at kolovratnik.net
Sat Mar 20 05:29:38 EDT 2021
On Sat, Mar 20, 2021 at 04:34:02AM -0400, Alan Bawden wrote:
> 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.
It would be great to read this reasoning in the documentation.
Cheers,
David
More information about the Python-list
mailing list