[issue12266] str.capitalize contradicts oneself

Marc-Andre Lemburg report at bugs.python.org
Thu Jul 21 10:34:22 CEST 2011


Marc-Andre Lemburg <mal at egenix.com> added the comment:

I think it would be better to use this code:

    if (!Py_UNICODE_ISUPPER(*s)) {
        *s = Py_UNICODE_TOUPPER(*s);
        status = 1;
    }
    s++;
    while (--len > 0) {
        if (Py_UNICODE_ISLOWER(*s)) {
            *s = Py_UNICODE_TOLOWER(*s);
            status = 1;
        }
        s++;
    }

Since this actually implements what the doc-string says.

Note that title case is not the same as upper case. Title case is
a special case that get's applied when using a string as a title
of a text and may well include characters that are lower case
but which are only used in titles.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12266>
_______________________________________


More information about the Python-bugs-list mailing list