[Python-Dev] surprising bug in s.capitalize()?
M.-A. Lemburg
mal@lemburg.com
Thu, 30 Nov 2000 19:38:04 +0100
> Oooh, here's something a bit more serious though:
>
> >>> u'aAaAaA'.capitalize()
> u'AAaAaA'
>
> Something obviously Needs To Be Done. My hunch is to change
> string_capitalize, but that may be just me (and probably Barry).
Ouch. That's a bug.
Here's what the string.py module has to say about this BTW:
# Capitalize a string, e.g. "aBc dEf" -> "Abc def".
def capitalize(s):
"""capitalize(s) -> string
Return a copy of the string s with only its first character
capitalized.
"""
return s.capitalize()
Note that .title() is very similar to the way string.capitalize()
works. unicode.title() also uses the title case information available
for Unicode characters.
--
Marc-Andre Lemburg
______________________________________________________________________
Company: http://www.egenix.com/
Consulting: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/