On Mon, Mar 22, 2021 at 12:26 PM Richard Damon <rich...@damon-family.org> wrote: > > On 3/21/21 7:31 PM, MRAB wrote: > > On 2021-03-21 22:30, Chris Angelico wrote: > >> On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards > >> <grant.b.edwa...@gmail.com> wrote: > >>> > >>> On 2021-03-21, Chris Angelico <ros...@gmail.com> wrote: > >>> > On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list > >>> <python-list@python.org> wrote: > >>> > > >>> >> I wonder if .title() properly capitalizes titles in any language. > >>> It doesn't in > >>> >> English (nor does it purport to), so it begs the question why it > >>> is there in > >>> >> the first place. German and Spanish don't have any special > >>> capitalization rules > >>> >> for titles; I don't know about any other languages. > >>> >> > >>> > > >>> > It correctly title-cases a single character, as has been pointed out > >>> > already. > >>> > >>> Not according to the docs. The doc states that .title() converts the > >>> first character characger in each "word" to _upper_ case. Is the doc > >>> wrong? > >>> > >>> If you want titlecase, then you should call str.capitalize() which > >>> (again according to the doc) converts the first character to _title_ > >>> case (starting in v3.8). > >>> > >> > >> Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine. > >> But maybe there's a better way to word it for both of them. > >> > > Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 > > 64 bit (AMD64)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> help(str.title) > > Help on method_descriptor: > > > > title(self, /) > > Return a version of the string where each word is titlecased. > > > > More specifically, words start with uppercased characters and all > > remaining > > cased characters have lower case. > > > > '\N{LATIN CAPITAL LETTER DZ}', '\N{LATIN SMALL LETTER DZ}' and > > '\N{LATIN CAPITAL LETTER D WITH SMALL LETTER Z}' are all digraphs, so > > is it correct to say that .title() uppercases the first character? > > Kind of. > > I think the clarification calling them upper cased characters is close > enough considering that there are only 31 title cased characters, all > digraphs. >
But it's wrong, and it would lead people to the exact error of thinking that it's the same as upper() on str[0] and lower() on the rest. ChrisA -- https://mail.python.org/mailman/listinfo/python-list