.title() - annoying mistake

Dan Stromberg drsalists at gmail.com
Fri Mar 19 15:58:50 EDT 2021


On Fri, Mar 19, 2021 at 11:51 AM Grant Edwards <grant.b.edwards at gmail.com>
wrote:

> On 2021-03-19, MRAB <python at mrabarnett.plus.com> wrote:
> > On 2021-03-19 17:19, Abdur-Rahmaan Janhangeer wrote:
> >> Aie sorry,
> >>
> >> Did not know it targetted the non-english speakers.
> >>
> > You want English "man's" to become "Man's", but French "l'homme" to
> > become "L'Homme". It's language-dependant.
>
> In English, certain words are not capitalized in titles unless they're
> the first word in the title (short articles and prepositions), and
> .title() doesn't get that right either:
>
> >>> "the man in the grey flannel suit".title()
> 'The Man In The Grey Flannel Suit'
>
> should be
>
> 'The Man in the Grey Flannel Suit'
>

In high school, I was taught that English has multiple capitalization
rulesets to choose among for titles.


More information about the Python-list mailing list