Skip to main content

PyPi Version python version downloads codecov

Python Table Print

A lightweight Python library for generating ASCII tables that automatically adjust their column widths to fit your data.

Installation

pip install python-table-print

Quick Start

PrintTable is the core class — add rows to it, then call get_table() to retrieve the formatted table as a string:

from table import PrintTable, Justification

schedule = PrintTable()
schedule.set_title("Solar System at a Glance")

schedule.add_row("Planet", "Type", "Moons", "Day Length", "Claim to Fame")
schedule.add_row("Mercury", "Terrestrial", "0",   "59 days",    "Closest to the Sun")
schedule.add_row("Venus",   "Terrestrial", "0",   "243 days",   "Hottest surface")
schedule.add_row("Earth",   "Terrestrial", "1",   "24 hours",   "Only known life")
schedule.add_row("Mars",    "Terrestrial", "2",   "24.6 hours", "Home of Olympus Mons")
schedule.add_row("Jupiter", "Gas giant",   "95",  "9.9 hours",  "Largest planet")
schedule.add_row("Saturn",  "Gas giant",   "146", "10.7 hours", "The ringed beauty")
schedule.add_row("Uranus",  "Ice giant",   "28",  "17.2 hours", "Rotates on its side")
schedule.add_row("Neptune", "Ice giant",   "16",  "16.1 hours", "Farthest from Sun")

schedule.set_column_justification(2, Justification.RIGHT)

print(schedule.get_table())
┌───────────────────────────────────────────────────────────────────┐
│                      Solar System at a Glance                     │
├─────────┬─────────────┬───────┬────────────┬──────────────────────┤
│ Planet  │ Type        │ Moons │ Day Length │ Claim to Fame        │
├─────────┼─────────────┼───────┼────────────┼──────────────────────┤
│ Mercury │ Terrestrial │     0 │ 59 days    │ Closest to the Sun   │
│ Venus   │ Terrestrial │     0 │ 243 days   │ Hottest surface      │
│ Earth   │ Terrestrial │     1 │ 24 hours   │ Only known life      │
│ Mars    │ Terrestrial │     2 │ 24.6 hours │ Home of Olympus Mons │
│ Jupiter │ Gas giant   │    95 │ 9.9 hours  │ Largest planet       │
│ Saturn  │ Gas giant   │   146 │ 10.7 hours │ The ringed beauty    │
│ Uranus  │ Ice giant   │    28 │ 17.2 hours │ Rotates on its side  │
│ Neptune │ Ice giant   │    16 │ 16.1 hours │ Farthest from Sun    │
└─────────┴─────────────┴───────┴────────────┴──────────────────────┘

get_table() returns the table as a plain string, so it can be passed to any function — not just print.

Usage

Header Row

By default, the first row is treated as a header and rendered with a separator below it. This can be toggled via the has_header_row property:

my_table.has_header_row = False

Title

A title can be added above the table with set_title(). It defaults to centre justification:

my_table.set_title("My Title")

To remove the title, call clear_title().

Justification

By default, all cells are left-justified. Justification can be set at four levels of granularity — each level overrides any previously set justification for the affected cells. The Justification enum must be imported alongside PrintTable.

Table-wide

from table import PrintTable, Justification

my_table.set_table_justification(Justification.CENTRE)

Row

my_table.set_row_justification(0, Justification.LEFT)

Column

my_table.set_column_justification(0, Justification.RIGHT)

Cell

my_table.set_cell_justification(1, 1, Justification.LEFT)

Justification for the title can also be set independently:

my_table.set_title_justification(Justification.LEFT)

License

MIT

Metadata

Release files for python-table-print 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-table-print 1.0.5
File Size Uploaded
python_table_print-1.0.5.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-table-print 1.0.5
File Interpreter ABI Platform
python_table_print-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / python_table_print-1.0.5.tar.gz

Download URL python_table_print-1.0.5.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d8ad9dd284c310a481d545330ef4fc50a63fab6657b7f4ca18a87ede655b6e7e
BLAKE2b-256 checksum
How to use checksums
90928c648c65bc111b95c4ce87177f5c126785a24c299bfa97bc43c60597044a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release files / python_table_print-1.0.5-py3-none-any.whl

Download URL python_table_print-1.0.5-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b62469fb96ab380cda37a9177e51bdffaa7842a4bfa7d8614bb3143405cef3a
BLAKE2b-256 checksum
How to use checksums
96698e2300b974cd43646163ac1a403489d079e1617bca4d8312a7034b5bd15d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.0

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.1

2 release files

0.4

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page