[Python-Dev] surprising bug in s.capitalize()?

M.-A. Lemburg mal@lemburg.com
Thu, 30 Nov 2000 19:19:29 +0100

"Barry A. Warsaw" wrote:
> I was just surprised by something I've never observed before from
> string.capitalize().  There is clearly either a bug (really two) in
> the code or in the documentation.
> >>> '__Myfoo'.capitalize()
> '__myfoo'
> Huh?  The documentation says:
>     capitalize ()
>        Return a copy of the string with only its first character capitalized.
> So it's only doing one of the three things it's promising!  For one
> thing, it's modifying something other than the first character, and
> for another, it's actually swapping the case of the character it /is/
> changing.  At least it returns a copy. :)
> Given the documentation, I would have expected the return value to be
> the same as the original string, i.e. unchanged.

Huh ? The "documentation" says that you will get a copy in which
only the first character is capitalized (and all others are
converted to lower-case).

> So which is it?  Does the description of the method need to be made
> more complicated, or does the code need to be simplified <wink>?

I'd say this is a documentation bug (and I'm authorized since
I wrote that snippet called "documentation" ;-).

Marc-Andre Lemburg
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/