This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: str.capitalize() should not lower the rest of the string
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eka, orsenthil, r.david.murray, terry.reedy
Priority: normal Keywords: patch

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:02adminsetgithub: 53337
2010-07-05 12:04:50orsenthilsetmessages: + msg109317
2010-07-05 11:44:08orsenthilsetstatus: open -> closed
resolution: fixed
messages: + msg109315

stage: patch review -> resolved
2010-07-04 01:10:38terry.reedysetstatus: closed -> open


keywords: + patch
nosy: + terry.reedy
messages: + msg109200
resolution: not a bug -> (no value)
stage: resolved -> patch review
2010-06-27 05:32:32orsenthilsetstatus: open -> closed

nosy: + orsenthil
messages: + msg108774

resolution: not a bug
stage: resolved
2010-06-27 05:00:55r.david.murraysetnosy: + r.david.murray
messages: + msg108773
2010-06-27 03:34:02ekacreate