.title() - annoying mistake

Thomas Jollans tjol at tjol.eu
Fri Mar 19 18:17:37 EDT 2021


On 19/03/2021 20:33, dn via Python-list wrote:
> On 20/03/2021 07.49, Grant Edwards wrote:
>> On 2021-03-19, MRAB <python at mrabarnett.plus.com> wrote:
>>> 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'
>
> To be fair, aren't book-titles* a (formalised) sub-set of the English
> language?

 From a quick scan of my (medium-sized) bookshelf, most publishers seem 
to agree that the thing to do is set the title in all caps. Of the few 
(English-language) books I have with any lower-case letters on the spine 
at all, most seem to follow the same general sort of rules for what 
words to capitalize, but ‘Last Chance To See’, capital T, by Douglas 
Adams, is one exception.

Of the others, I noticed that ‘The Life and Times Times of The 
Thunderbolt Kid’ by Bill Bryson has an interesting choice of 
capitalization which is perfectly logical but certainly not the only option.





More information about the Python-list mailing list