Titlecase: A Great Find ####################### :title: Titlecase: A Great Find :date: 2014-09-18 :category: Software :tags: programming, python, blogging :slug: titlecase-a-great-find :author: Chris Ramsay :status: published :language: en :show_source: True .. contents:: Title Case ---------- .. PELICAN_BEGIN_SUMMARY 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`_. .. PELICAN_END_SUMMARY Up and Running -------------- Getting titlecase up and running couldn't be simpler: .. code-block:: bash $ 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: .. code-block:: python $ 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. .. _`yourdictionary.com's`: http://grammar.yourdictionary.com/capitalization/rules-for-capitalization-in-titles.html .. _`Pat Pannuto's`: http://patpannuto.com .. _`titlecase package`: https://github.com/ppannuto/python-titlecase