Message93242
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 B\tC\r\nD') returns 'A
B C D'.
The title() method exists primarily because the Unicode standard has a
definition of "title case". I wouldn't want to change its default
behavior because there is no reasonable behavior that isn't locale-
dependent, and Unicode methods shouldn't depend on locale; and even then
it won't be perfect, as the O'Brien example shows.
Also note that .title() matches .istitle() in the sense that
x.title().istitle() is supposed to be true (except in end cases like a
string containing no letters).
I worry that providing an API that adds a way to specify a set of
characters to be treated as letters (for the purpose of deciding where
words start) will just make the bugs in apps harder to find because the
examples are rarer (like "l'Aperitif" or "O'Brien" -- or "RSVP" for that
matter). With the current behavior at least app authors will easily
notice the problem, decide whether it matters to them, and implement
their own algorithm if they do. And they are free to be as elaborate or
simplistic as they care.
What's a realistic use case for .title() anyway?
(Proposal: close as won't fix.) |
|
Date |
User |
Action |
Args |
2009-09-28 23:02:54 | gvanrossum | set | recipients:
+ gvanrossum, nnorwitz, rhettinger, pitrou, ezio.melotti, r.david.murray, markon, twb, nickd |
2009-09-28 23:02:53 | gvanrossum | set | messageid: <1254178973.99.0.0865778223053.issue7008@psf.upfronthosting.co.za> |
2009-09-28 23:02:52 | gvanrossum | link | issue7008 messages |
2009-09-28 23:02:51 | gvanrossum | create | |
|