.title() - annoying mistake

Benjamin Schollnick bschollnick at schollnick.net
Sun Mar 21 07:38:46 EDT 2021


>> The problem is that you haven't read the documentation :) It very carefully
>> does NOT define itself by language, and its behaviour is identical regardless
>> of the language used.
> 
> The documentation says: "The algorithm uses a simple language-independent
> definition of a word as groups of consecutive letters..."
> 
> Yes, I get that. But the purpose it (improperly) serves only makes sense in the
> English language. Which is also the reason they called it title() and not
> capitalize_words(). Frankly, I can't think of any situation where this method
> would have any use -- in any language, including English. It is just a
> completely arbitrary feature, as would be a function that capitalizes only the
> last letter of each word.

I’m sorry Robert, but just because it doesn’t meet your requirements, doesn’t mean it’s useless.

I use .title to normalize strings for data comparison, all the time.  It’s a perfect alternative to
using .UPPER or .lower.  

Right in the documentation, it specifically acknowledges .title working in foreign character sets. 

So while I feel for the fact that it doesn’t met your requirements, please keep in mind, it does meet other peoples requirements.  

As with everything here, it’s open source.  If you feel that there should be a revised version that does met your requirements create it, or gather a bunch of people and go the route of SCANDIR and open-source it, and petition that it be moved into the standard library.

Since this seems to be bugging you this much, come up with a solution.  

I suspect the problem you are going to have is that in effect you’ll be creating a multi-language parser, even worse, you may have to add nameparsing into this.

Good luck.

	- Benjamin





More information about the Python-list mailing list