Skip to main content

A pretty-printing library for dicts, lists, tables, and JSON.

Project description

PrintCraft 🖨️✨

Beautifully formatted console printing for Python.

PrintCraft is a lightweight library that makes Python data structures easy to read in the terminal.
Unlike pprint, tabulate, or rich, it combines multiple formatters, themes, and an auto-detection engine in one small package.


🚀 Why PrintCraft?

  • All-in-one → JSON, tables, dicts, lists, preview.
  • 🎨 Theme-able → consistent styling across everything.
  • 🤖 Smart auto-detection → just call pcraft(data) and it picks the best format.
  • Lightweight → no heavy dependencies (unlike rich).
  • 🧩 Pluggable → extend with your own formatters & themes.

Comparison

Feature pprint tabulate rich PrintCraft
JSON Formatting
Tables
Dict Formatting ⚠️ basic ✅ aligned
Lists/Tuples ⚠️ compact ✅ beautifier
Themes/Colors
Auto-Detection
Dependencies none small large minimal

📦 Installation

pip install printcraft

⚡ Usage & Commands (Functions)

1. pjson(data, theme="default")

Pretty-print JSON objects with optional color themes.

from printcraft import pjson

sample = {"name": "Afaq", "age": 23, "active": True}
pjson(sample, theme="monokai")

2. ptable(rows, style="ascii")

Format tabular data as ASCII, Unicode, Markdown, or HTML tables.

from printcraft import ptable

rows = [["ID", "Name"], [1, "Tamjeed"], [2, "Yasoha"]]
ptable(rows, style="unicode")

3. pdict(data)

Nicely aligned dictionary printing.

from printcraft import pdict

d = {"alpha": 1, "beta": 22, "gamma": 333}
pdict(d)

4. plist(data, compact=False)

Format lists/tuples with optional compact mode.

from printcraft import plist

plist([1, 2, 3, 4, 5], compact=True)

5. ppreview(data, max_items=5)

Preview large structures without dumping everything.

from printcraft import ppreview

ppreview(list(range(100)), max_items=10)

6. pcraft(data)

Auto-detect → decides best format automatically.

from printcraft import pcraft

pcraft({"alpha": 1, "beta": 2})   # Uses dict formatter
pcraft([1, 2, 3, 4, 5])           # Uses list formatter
pcraft([["A", "B"], [1, 2]])      # Uses table formatter

🧪 Tests

pytest tests/

Function / Class Parameter Allowed / Typical Values Notes
json() obj Any JSON-serializable dict/list
indent 1,2,3,... Number of spaces for pretty-print
theme "default", "dark" (or any defined in themes.py) Color scheme for keys/values
stream None (stdout) or file-like object Redirect output to file
table() data List of dicts / list of lists Single dict must be wrapped in [dict]
headers List of strings Optional column headers
style "ascii", "unicode" ASCII: + - , Unicode: ┼ ─ │\
dict() d dict
max_items 1,2,... Maximum keys to display before truncating
list() lst list/tuple
max_items 1,2,... Maximum items to display before truncating
preview() obj any Python object Works with dict, list, string, number, etc.
max_items 1,2,... Items shown for collections
craft() obj any Python object Auto-selects formatter: json, table, dict, list, preview
max_items 1,2,... Used for truncating lists/dicts
PrintCraftFormatter pretty True / False Pretty formatting for logs
themes.py Theme names "default", "dark" Can define new themes with "key", "string", "number", "reset" ANSI codes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

printcraft-1.0.2.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

printcraft-1.0.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file printcraft-1.0.2.tar.gz.

File metadata

  • Download URL: printcraft-1.0.2.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for printcraft-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9f893543e872b3c27c555ebf79ee873cbe7a979d89fe2a47bbfd3c4091670c7a
MD5 1c4e667f13d7abcf867e26eff033ddac
BLAKE2b-256 dad8ce447cd566a24e493cbcadae830d2d997f036d2c9a64803ee705ce74ab68

See more details on using hashes here.

File details

Details for the file printcraft-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: printcraft-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for printcraft-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a688265b9085467a1980d0e3a306da65578face25dd331ec457ea21fbd3af28
MD5 bf1ecfb8b604da2ee0a14e338020d34f
BLAKE2b-256 b75635f6fc5c9cdadd2cd563eb0587efc80f83660e56e536d08ca275c67d40ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page