.title() - annoying mistake

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Sat Mar 20 02:07:32 EDT 2021


Greetings,

Missing the 'S renders in my opinion the method unfit to be included
in it's current form.

It is a call to improve it if possible. We wonder why in the first place
such a
method exists. If indeed it intends to capitalise all first letters, putting
others in lowercase, the ' is a too common case to be ignored.

The intent was:

"Return a titlecased version of the string where words start with an
uppercase
character and the remaining characters are lowercase."

But the ' is a case acknowledged by the docs:

"The algorithm uses a simple language-independent definition of a word as
groups of consecutive letters. The definition works in many contexts but it
means that apostrophes in contractions and possessives form word
boundaries,
which may not be the desired result:
...
A workaround for apostrophes can be constructed using regular expressions:
..."

Why not do it if you know people miss it?

Kind Regards,

Abdur-Rahmaan Janhangeer
about <https://compileralchemy.github.io/> | blog
<https://www.pythonkitchen.com>
github <https://github.com/Abdur-RahmaanJ>
Mauritius


More information about the Python-list mailing list