[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Guido van Rossum
Changes by Guido van Rossum : -- assignee: gvanrossum -> nosy: -gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Christoph Burgmer
Christoph Burgmer added the comment: Antoine Pitrou wrote: > capwords() itself could be deprecated, since it's an obvious one- > Replacing in with another method, however, will just confuse and annoy > existing users. Yes, sorry, I meant the semantics, where as you are right for the specific fu

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Christoph Burgmer wrote: > > Christoph Burgmer added the comment: > > I admit I don't fully understand the semantics of capwords(). string.capwords() is an old function from the days before Unicode. The function is basically defined by its implementation

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: > This algorithm should be implemented anyway, to properly solve > issue6412. Sure, but it should be another function, which might have its place in the wordwrap module. capwords() itself could be deprecated, since it's an obvious one-liner. Replacing in with

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Christoph Burgmer
Christoph Burgmer added the comment: I admit I don't fully understand the semantics of capwords(). But from what I believe what it should do, this function could be happily replaced by the word-breaking algorithm as defined in http://www.unicode.org/reports/tr29/. This algorithm should be imple

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Ezio Melotti wrote: > > Ezio Melotti added the comment: > >> Patches to enhance the code to support those additional rules > are welcome. > > #6412 has a patch. That patch looks promising. -- ___ Python trac

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: > To make things even more complicated, the usual typewriter apostrophe > that you find in ASCII is not the only one in Unicode: > > http://en.wikipedia.org/wiki/Apostrophe#Unicode Yup, and the right one typographically isn't necessarily the ASCII one :-) That

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Ezio Melotti
Ezio Melotti added the comment: > Patches to enhance the code to support those additional rules are welcome. #6412 has a patch. -- assignee: -> gvanrossum ___ Python tracker __

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Marc-Andre Lemburg wrote: > > Regarding the apostrophe: the Unicode standard doesn't appear to > include any rule regarding that character and its use in titles > or upper-case versions of text. The apostrophe itself is a > non-cased code point. > > It's l

[issue7008] str.title() misbehaves with apostrophes

2009-09-29 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Guido van Rossum wrote: > What's a realistic use case for .title() anyway? The primary use is when converting a string to be used as title or sub-title of text - mostly inspired by the way English treats titles. The implementation follows the rules laid ou

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Neal Norwitz
Neal Norwitz added the comment: I don't recall anything specifically wrt removing capwords. Most likely it was something that struck me as not widely used or really necessary--a good candidate to be removed. Applications could then write the fucntion however they chose which would avoid the pr

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: I will add a comment to the docs. -- resolution: -> wont fix status: open -> closed ___ Python tracker ___ _

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Guido van Rossum
Changes by Guido van Rossum : -- assignee: gvanrossum -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:/

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Guido van Rossum
Guido van Rossum added the comment: A doc fix sounds like a great idea. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Guido van Rossum
Guido van Rossum added the comment: Raymond, please refrain from emotional terms like "bug factory". I have nothing to say about whether string.capwords() should be removed, but I want to note that it does a split on whitespace and then rejoins using a single space, so that string.capwords('A

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: By the way, we might want to mention in the documentation that the title() method only gives imperfect results when trying to titlecase natural language. So that people don't get fooled thinking things are simple :-) What do you think? -- _

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: > While > the change would seem to always be helpful in an English context, in > French the proper title casing of "l'argent" is "L'Argent". Well I think even in English it doesn't work right. For example someone named O'Brien would end up as "O'brien". My poi

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Ezio Melotti
Ezio Melotti added the comment: > I think Ezio found some other information somewhere. While I was fixing #7000 I found that the tests for capwords had been removed in r54854 but since the function was already there I added them back in r75072. The commit message of r54854 says "Also remove all

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Guido, do you have an opinion on whether to have str.title() handle embedded apostrophes, "you're" --> "You're" instead of "You'Re"? IMO, the problem comes-up often enough that people are looking for workarounds (i.e. string.capwords() was a failed hack crea

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Antoine Pitrou
Antoine Pitrou added the comment: We shouldn't change the current default behaviour, people are probably relying on it. Besides, doing the right thing is both (natural) language-dependent and context-dependent. It would be (very) hard to come with an implementation catering to all needs. Perhap

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thomas, if you write-up an initial patch, aim for the most conservative version that leaves all of the behavior unchanged except for embedded single apostrophes (to handle contractions and possessives). That will assure that we don't muck-up any existing use

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm still researching what other languages do. MS-Excel matches what Python currently does. Django uses the python version and then fixes-up apostrophe errors: title=lambda value: re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title()).

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Thomas W. Barr
Thomas W. Barr added the comment: If "correct handling of apostrophe's and quotation marks, keeping the string length unchanged, and only changing desired letters from lower to uppercase with no other side-effects" is the criterion we want, then what I suggested (toupper() the first character, a

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread R. David Murray
R. David Murray added the comment: I haven't been able to find any discussion of deprecating capwords other than a mention in this thread: http://mail.python.org/pipermail/python-3000/2007-April/006642.html Later in the thread Barry says he is neutral on removing capwords, and it is not mentio

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http:

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: If you can find a link to the discussion for removing capwords, we can go ahead and deprecate it now. -- ___ Python tracker ___ _

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread R. David Murray
R. David Murray added the comment: I believe capwords was supposed to be removed in 3.0, but this did not happen. -- nosy: +r.david.murray priority: -> normal stage: -> test needed ___ Python tracker

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: I agree with the OP that str.title should be made smarter. As it stands, it is a likely bug factory that would pass unittests, then generate unpleasant results with real user inputs. Extending on Thomas's comment, I think string.capwords() needs to be depre

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Thomas W. Barr
Thomas W. Barr added the comment: The string module, however, fails to properly capitalize anything in quotes: >>> string.capwords("i pity the 'foo'.") "I Pity The 'foo'." The string module could be easily made to work like the object. The object could be made to work more like the module, onl

[issue7008] str.title() misbehaves with apostrophes

2009-09-28 Thread Marco B
Marco B added the comment: This was already asked some years ago. http://mail.python.org/pipermail/python-list/2006-April/549340.html -- nosy: +markon ___ Python tracker ___ ___

[issue7008] str.title() misbehaves with apostrophes

2009-09-27 Thread Nick Devenish
New submission from Nick Devenish : str.title() capitalizes the first letter after an apostrophe: >>> "This isn't right".title() "This Isn'T Right" The library function string.capwords, which appears to have exactly the same responsibility, doesn't exhibit this behavior: >>> string.capwords("T