.title() - annoying mistake

Gene Heskett gheskett at shentel.net
Mon Mar 22 23:02:54 EDT 2021


On Monday 22 March 2021 22:31:27 Richard Damon wrote:

> On 3/22/21 4:20 PM, Christian Gollwitzer wrote:
> > Am 22.03.21 um 16:03 schrieb Robert Latest:
> >> Chris Angelico wrote:
> >>> Cool thing is, nobody in Python needs to maintain anything here.
> >>
> >> That's great because I'm actually having trouble with sending log
> >> messages over
> >> the socket conection you helped me with, would you mind having a
> >> look?
> >
> > You misunderstood the "here".
> >
> > (native German as well, but I think it means "for keeping .title()
> > up to date)
> >
> > I agree with Chris that .title() can be useful for "title-casing" a
> > single character, whatever that means. It should be documented,
> > though, that it is not suitable to title-case a string, not even in
> > English.
> >
> >     Christian
>
> Part of the difficulty in getting clear documentation for this is that
> is it IS somewhat complicated. You title-case a string by Title-casing
> the first character of each word (and the primary issue error that
> started this was the definition of a 'word'), and lower casing the
> rest of the word. The complication comes in that title-casing a
> character 99.99% of the time doesn't give you a character in
> title-case, but more often in upper-case (or uncased). There are
> apparently only 31 actual characters that are 'Title-Case'. Thus the
> action of 'title-casing' a character is a bit strange to describe,
> especially to people used to simple languages which don't have any of
> the characters that cause the issue.
>
> We don't seem to have a problme that upper doesn't always return a
> true 'upper-case', like for '1' because we realize that many character
> don't have case, so it gets largly just assumed we know that. For
> title case, the fact that almost all characters do NOT have a
> 'title-case' form makes things a bit more awkward.
>
> Yes, perhaps the documentation could be made a bit more clear. I do
> note that the documentation for str.capitalize() does talk about using
> actual title case characters if the first character is a digraph.
> Something like that might make sense in the description of str.title()
>
> Note, that str.istitle() doesn't actually check if the character is a
> real 'title case' character, but that the string follows a rule
> similar to what str.title() produces. I am not positive that its
> description exactly matches what .title() produces, but it close, and
> the way it is written, "Python's".istitle() is False, as the s at the
> end needs to be uppper case to satisfy as ' is uncased, so the next
> cased character must be upper case.
>
> --
> Richard Damon

I am as tired of this thread as anybody here. To me, it must be capable 
to subbing a considerably more caligraphic attention getting font and  a 
bit larger in order for it to be worth its space on the drive. We can do 
that in openoffice and its ilk with a bit of bother, but it can be done.  
Learning how to use this just adds more bother because you can do it by 
hand quicker than looking up the man page for this. OTOH, in the average 
title, that should be restricted to the first character only.

However, we've beat this horse to death, so it is not going to rear up 
and win the next Derby. So dig a hole and bury it please.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


More information about the Python-list mailing list