[Tutor] string.title(): correct?
Christoph Burgmer
cburgmer at ira.uka.de
Thu Aug 27 17:15:56 CEST 2009
> Allen Fowler wrote:
> > Hello,
> >
> > "He's a great guy".title()
> >
> > Gives me:
> >
> > "He'S A Great Guy"
> >
> >
> > I expected:
> >
> > "He's A Great Guy"
> >
> > Did i miss something here?
>
> The docs state:
>
> "title( ) - Return a titlecased version of the string: words start with
> uppercase characters, all remaining cased characters are lowercase."
>
> It depends on the definition of "word".
Yes, but in this case Python is wrong.
Titlecase should, at least for Unicode strings, follow the Unicode "Default
Case Algorithms", see bug http://bugs.python.org/issue6412.
http://www.unicode.org/Public/5.2.0/ucd/DerivedCoreProperties-5.2.0d15.txt
lists:
0027 ; Case_Ignorable # Po APOSTROPHE
An as such the following would be correct:
>>> "He's a great guy".title()
"He's A Great Guy"
I'm not subsribed to the list, CC me for answer.
-Christoph Burgmer
More information about the Tutor
mailing list