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/

📖 Examples

See examples/ for:

  • json_example.py
  • table_example.py
  • auto_detect_example.py

Function / Class Parameter Allowed / Typical Values Notes
json() obj Any JSON-serializable dict/list
color True / False Applies ANSI colors in terminal
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: ┼ ─ │\
color True / False Colors first column numbers
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
color True / False Applies only if formatter supports it
max_items 1,2,... Used for truncating lists/dicts
PrintCraftFormatter pretty True / False Pretty formatting for logs
color True / False Adds color codes for log output
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.1.tar.gz (12.8 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.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: printcraft-1.0.1.tar.gz
  • Upload date:
  • Size: 12.8 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.1.tar.gz
Algorithm Hash digest
SHA256 26c8d03244b39006f545bfdcc61f839cbce9cd91a38d953ee64b26e5778db2c7
MD5 b494aa5c6e766e0d63feec6afa784684
BLAKE2b-256 29d74295fe40e6c1dbf4a76df996a776c2fa742d55be545de4d774b70be60500

See more details on using hashes here.

File details

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

File metadata

  • Download URL: printcraft-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37593782b1bd43afda4f784b40c5c5776d64f98612eb787a4090f8bc3ebf040c
MD5 e59823b89ebe4f87026cbd9154ec8f67
BLAKE2b-256 8a0f150a3eb18f719a7a36d9a1ebeac8fe3fac40c461a3e5e493db4febbad26b

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