PrettyTable 0.1 released
Published: February 25, 2009Tags: software prettytable
Today I released a simple Python library that I wrote during a 3 hour train ride from Newcastle to Sydney last weekend (more on what I was doing there in a later enry!), which I've decided to call PrettyTable. It contains a single class of that name whose job is to make it easy to print nice-looking ASCII tables like this:
+-----------+------+------------+-----------------+
| City name | Area | Population | Annual Rainfall |
+-----------+------+------------+-----------------+
| Adelaide | 1295 | 1158259 | 600.5 |
| Brisbane | 5905 | 1857594 | 1146.4 |
| Darwin | 112 | 120900 | 1714.7 |
| Hobart | 1357 | 205556 | 619.5 |
| Sydney | 2058 | 4336374 | 1214.8 |
| Melbourne | 1566 | 3806092 | 646.9 |
| Perth | 5386 | 1554769 | 869.4 |
+-----------+------+------------+-----------------+
Some of you may recognise the style of table from the PostgreSQL shell psql, which was the inspiration for PrettyTable.
It's quite a simple little piece of code (you can read about the various options at the page linked to above, and you can even see the Pydoc API - this is actually the first time I've used Pydoc on my own software!) but it's also the kind of thing that I suspect will actually find use in a wide range of future projects, both of my own and hopefully of others.