.title() - annoying mistake
Grant Edwards
grant.b.edwards at gmail.com
Mon Mar 22 09:07:34 EDT 2021
On 2021-03-21, MRAB <python at mrabarnett.plus.com> wrote:
IMO, the doc is wrong.
>> 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 guess it depends on what you mean by "character". In my mind, the
first character of string s is s[1], and I would then expect that
s.title()[1] == s[1].upper()
--
Grant
More information about the Python-list
mailing list