Marc-Andre Lemburg <m...@egenix.com> 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 out in UTR#21: http://unicode.org/reports/tr21/tr21-3.html The Python version only implements the basic set of rules, i.e. "If the preceeding letter is cased, chose the lowercase mapping; otherwise chose the titlecase mapping (in most cases, this will be the same as the uppercase, but not always)." It doesn't implement the special casing rules, since these would require locale and language dependent context information which we don't implement/use in Python. It also doesn't implement mappings that would result in a change of length (ligatures) or require look-ahead strategies (e.g. if the casing depends on the code point following the converted code point). Patches to enhance the code to support those additional rules are welcome. 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 likely that the special use of the apostrophe in English is actually a language-specific use case. For those, it's (currently) better to implement your own versions of the conversion functions, based on the existing methods. Regarding the idea to add an option to define which characters to regard as cased/non-cased: This would cause the algorithm to no longer adhere to the Unicode standard and most probably cause more problems than it solves. ---------- nosy: +lemburg _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7008> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com