tinytab

A tiny package that formats values and renders small tables. Really, though, it's a teaching resource: a complete, working example of how to package, test, and document a Python library.

AI / Agents

Skills
llms.txt
llms-full.txt

Developers

Richard Iannone

Maintainer

Community

Full license MIT

Meta

Requires: Python >=3.10
Provides-Extra: dev, docs
Package Info

Show the code
from tinytab import Table, fmt_currency, fmt_number

menu = Table(
    {
        "item": ["coffee", "bagel", "croissant"],
        "price": [3.5, 2.25, 4.0],
        "sold": [120, 45, None],
    }
)

menu.fmt("price", fmt_currency).fmt("sold", lambda x: fmt_number(x, decimals=0))
itempricesold
coffee$3.50120
bagel$2.2545
croissant$4.00

That’s tinytab in a nutshell: a small table, with a formatter attached to two of its columns.

Why tinytab?

tinytab formats values and renders small tables, as text or HTML. It’s a morsel of Great Tables: a few formatting functions and a very simple table class, with no dependencies.

But tinytab isn’t really meant to be used. It’s an example: a small, complete Python package whose packaging, tests, type checking, CI, and documentation are all set up the way a real library’s would be, so each part can be studied on its own and seen working together. This site is part of the example, too.

What’s on this site

  • User Guide: how to use tinytab, from formatting a single number to rendering and saving tables
  • Reference: every function and class, generated from the docstrings, with examples that show their real output
  • Python Packaging: the opinionated set of practices that tinytab demonstrates, covering project setup, testing, CI, code and API design, and documentation

Installation

tinytab isn’t published on PyPI. Install it from GitHub:

Terminal
pip install git+https://github.com/rich-iannone/example-python-package.git

The source code, with its tests and configuration, is in the GitHub repository.