.title() - annoying mistake

Richard Damon Richard at Damon-Family.org
Sun Mar 21 08:37:14 EDT 2021


On 3/21/21 8:19 AM, Albert-Jan Roskam wrote:
>    On 20 Mar 2021 23:47, Cameron Simpson <cs at cskk.id.au> wrote:
>
>      On 20Mar2021 12:53, Sibylle Koczian <nulla.epistola at web.de> wrote:
>      >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. [...]
>      >>
>      >But that's exactly what he's doing, with a result which is documented,
>      >but not really satisfactory.
>
>    ====
>    This would be a good
>    start: https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
>    It could be locale-dependent. What I also don't like about .title() is
>    that it messes up abbreviations ("Oecd")

The built in title() function is basically an intentionally 80%
solution. It handles the simple cases simply, and if you might have the
more complicated cases, you have to handle that yourself because to
specify what the 'right' answer would be is basically impossible to do
in general (because there are conflicting definitions, and some things
require context beyond what just its input provides).

-- 
Richard Damon



More information about the Python-list mailing list