Message93235
| Author |
rhettinger |
| Recipients |
ezio.melotti, markon, nickd, r.david.murray, rhettinger, twb |
| Date |
2009年09月28日.21:02:22 |
| SpamBayes Score |
3.13618e-05 |
| Marked as misclassified |
No |
| Message-id |
<1254171744.57.0.855191107022.issue7008@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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()).
It would also be nice to handle hyphenates like "xray" --> "X-ray".
Am thinking that it would be nice if the user could pass-in an optional
argument to list all desired characters to prevent transitions (such as
apostrophes and hyphens).
A broader solution would be to replace string.capwords() with a more
sophisticated set of rules that generally match what people are really
trying to accomplish with title casing:
http://aitech.ac.jp/~ckelly/midi/help/caps.html
http://search.cpan.org/dist/Text-Capitalize/Capitalize.pm
"Headline Style" in the Chicago Manual of Style or
Associate Pressd Stylebook:
http://grammar.about.com/b/2008/04/11/rules-for-capitalizing-the-words-in-a-title.htm
Any such attempt at a broad solution needs to provide ways for users to
modify the list of exception words and options for quoted text. |
|