str.title() fails with words containing apostrophes

Steve D'Aprano steve+python at pearwood.info
Mon Mar 6 18:07:47 EST 2017


On Tue, 7 Mar 2017 03:28 am, Grant Edwards wrote:

> On 2017-03-06, Chris Angelico <rosuav at gmail.com> wrote:
> 
>> Still, it's fun to discuss, if only to show why that kind of
>> locale-aware transformation is important.
> 
> Besides locale-aware, it'll need to be style-guide-aware so that it
> knows whether you want MLA, Chicago, Strunk & White, NYT, Gregg,
> Mrs. Johnson from 9th grade English class, or any of a dozen or two
> others.  And that's just for US English.  [For all I know, most of the
> ones I listed agree completely on "title case", but I doubt it.]

As far as I am aware, there are only two conventions for title case in
English:

Initial Capitals For All The Words In A Sentence.

Initial Capitals For All the Significant Words in a Sentence.

For some unstated, subjective rule for "significant" which usually
means "three or more letters, excluding the definite article ('the')".

But of course there are exceptions: words which are necessarily in all-caps
should stay in all-caps (e.g. NASA) and names.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list