.title() - annoying mistake

Chris Angelico rosuav at gmail.com
Mon Mar 22 11:34:57 EDT 2021


On Tue, Mar 23, 2021 at 2:28 AM Grant Edwards <grant.b.edwards at gmail.com> wrote:
> The document for str.title() states that the initial character of each
> word is converted to uppercase.  My point is that for characters that
> remain single characters regardless of case that means (to me) that
>
>   s.title()[0] == s[0].upper()
>
> or for a single character string
>
>   s.title() == s.upper()
>
> That's not true for digraphs where there is a third, distinct and
> different "title" case. I think the doc should state that the initial
> character is converted to titlecase. A parenthentical statement that
> titlecase is usually but not always equal to uppercase would be nice,
> but the current statement is obsolete and not correct in all, um...
> cases.

Fair enough, but the trouble is that getting too pedantic in a
docstring just makes it read like IBM documentation. :)

ChrisA


More information about the Python-list mailing list