Issue 9091: str.capitalize() should not lower the rest of the string (original) (raw)

Created on 2010-06-27 03:34 by eka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg108772 - (view) Author: Esteban Feldman (eka) Date: 2010-06-27 03:34
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'
msg108773 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-06-27 05:00
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.
msg108774 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-06-27 05:32
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.
msg109200 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-04 01:10
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.
msg109315 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-07-05 11:44
Fixed it in r82570. Hyper linking lowered was leading to something like str.lower ed. So, I simply left it.
msg109317 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-07-05 12:04
Updated the docstrings in r82573.
History
Date User Action Args
2022-04-11 14:57:02 admin set github: 53337
2010-07-05 12:04:50 orsenthil set messages: +
2010-07-05 11:44:08 orsenthil set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2010-07-04 01:10:38 terry.reedy set status: closed -> openkeywords: + patchnosy: + terry.reedymessages: + resolution: not a bug -> (no value)stage: resolved -> patch review
2010-06-27 05:32:32 orsenthil set status: open -> closednosy: + orsenthilmessages: + resolution: not a bugstage: resolved
2010-06-27 05:00:55 r.david.murray set nosy: + r.david.murraymessages: +
2010-06-27 03:34:02 eka create