Contents
Title Case
As a rather inexperienced writer, it is the little things I struggle with, as well as the big things you might add. I find that one of the most annoying is getting title case correct. There are a lot of style guides about which may or may not help; I find some of them cryptic at times, and rather than being strict rules, they seem to be more matters of style. Until recently I had been taking style advice from yourdictionary.com's site, but I always found having to undertake this task manually a bit of a bore.
However, as with most programmers (or even ex-programmers like myself), I find that as soon as I am faced with a repetetive task I look to find a way of automating it; and thus it happened with this. Five minutes later and I had turned up Pat Pannuto's Python based titlecase package.
Up and Running
Getting titlecase up and running couldn't be simpler:
$ pip install titlecase
Downloading/unpacking titlecase
Downloading titlecase-0.7.1.tar.gz
Running setup.py (path:/home/vagrant/Envs/blog/build/titlecase/setup.py) egg_info for package titlecase
no previously-included directories found matching 'doc/.build'
Installed /home/vagrant/Envs/blog/build/titlecase/nose-1.3.4-py2.7.egg
Installing collected packages: titlecase
Running setup.py install for titlecase
Successfully installed titlecase
Cleaning up...
Using it couldn't be much simpler either:
$ python
Python 2.7.3 (default, Jan 2 2013, 13:56:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from titlecase import titlecase
>>> titlecase('the lion, the witch and the wardrobe')
'The Lion, the Witch and the Wardrobe'
>>> titlecase('Titlecase: a Great find')
'Titlecase: A Great Find'
>>> titlecase('Why it is never too late to learn grammar')
'Why It Is Never Too Late to Learn Grammar'
So, in summation, thumbs up to Mr Pannuto and thanks for such a useful library. I plan to make much use of it in the future.
Comments
comments powered by Disqus