.title() - annoying mistake

Chris Angelico rosuav at gmail.com
Sun Mar 21 23:17:18 EDT 2021


On Mon, Mar 22, 2021 at 2:00 PM Richard Damon <Richard at damon-family.org> wrote:
> Basically, titlecasing a word IS making the first letter upper case and
> the rest lower case UNLESS the first letter is on of the 31 digraphs
> which have a special titlecase version, then that is used for the first
> letter. That gets pretty wordy for an explanation string.

It title cases. I don't understand what's a problem here. With
str.casefold(), there's no detailed explanation of how it's usually
equivalent to lowercasing - it just says that it returns a string
suitable for caseless comparisons. Unicode defines many things about
characters, and often the differences don't matter to a large subset
of those characters, but the differences exist for a reason, and lying
in the docstring isn't going to help anything.

It doesn't "uppercase unless it's one of this small group of
characters". It "title cases".

ChrisA


More information about the Python-list mailing list