Python Port of John Gruber's titlecase.pl
This filter changes all words to Title Caps, and attempts to be clever about SMALL words like a/an/the in the input.
The list of “SMALL words” which are not capped comes from the New York Times Manual of Style, plus some others like ‘vs’ and ‘v’.
Issues, updates, pull requests, etc should be directed to github.
The easiest method is to simply use pip:
(sudo) pip install titlecase
Titlecase provides only one function, simply:
>>> from titlecase import titlecase >>> titlecase('a thing') 'A Thing'
A callback function may also be supplied, which will be called for every word:
>>> def abbreviations(word, **kwargs): ... if word.upper() in ('TCP', 'UDP'): ... return word.upper() ... >>> titlecase.titlecase('a simple tcp and udp wrapper', callback=abbreviations) 'A Simple TCP and UDP Wrapper'
The callback function is supplied with an all_caps keyword argument, indicating whether the entire line of text was entirely capitalized. Returning None from the callback function will allow titlecase to process the word as normal.
Command Line Usage
Titlecase also provides a command line utility titlecase:
$ titlecase make me a title Make Me a Title $ echo "Can pipe and/or whatever else" | titlecase Can Pipe and/or Whatever Else # Or read/write files: $ titlecase -f infile -o outfile
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size titlecase-0.12.0-py3-none-any.whl (9.7 kB)||File type Wheel||Python version 3.6||Upload date||Hashes View hashes|
|Filename, size titlecase-0.12.0.tar.gz (7.0 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for titlecase-0.12.0-py3-none-any.whl