As per documentation: I doesn't say anything on lower the rest of the string. Is this the expected behavior? ** str.capitalize()ΒΆ Return a copy of the string with only its first character capitalized. For 8-bit strings, this method is locale-dependent. ** Example: Python 2.6.5 (r265:79063, May 24 2010, 14:03:08) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> a = 'this is a TEST' >>> a.capitalize() 'This is a test'
The doc looks pretty clear to me: "return a copy of the string with *only* its first character capitalized." I don't offhand see how we could make that clearer. Maybe we should actually put the emphasis on the 'only' into the doc markup? That doesn't feel quite right to me, though.
Capitalization is a language property, it is not Python specific. By Definition, except for first letter every thing else is lower cased. http://en.wikipedia.org/wiki/Capitalization So, Python documentation assumes that it is understood (or can referred to in case of doubt). I too don't see any change is required in Python docs.
I disagree and recommend adding " and the rest lowered". 'lower' could be marked as a reference to the .lower method. If one interprets 'capitalized' as an adjective describing the result, then it is fairly clear. If one interprets it as describing a process applied to only the first char, then is it not clear that something else (the inverse operation) is done to the rest. This additional would complete the description of the operation. With that addition, 'only' could be removed, so it reads "Return a copy of the string with its first character capitalized and the rest lowered." or 'lower-cased' or 'lowercased' as the editor prefers. Loading 'only' to mean 'and the rest lowered' is a bit much and not necessary.