Skip to main content

The most sophisticated debug printing library for Python - IceCream + Rich fusion with syntax highlighting and beautiful tracebacks

Project description

LitPrinter Logo

🔥 LitPrinter

IceCream + Rich = LitPrinter — The ultimate debug printing library for Python

A powerful fusion of IceCream-style debugging with Rich-style formatting, syntax highlighting, and beautiful tracebacks.

Version Python License IceCream Compatible

🚀 Why LitPrinter?

LitPrinter is a drop-in replacement for IceCream with additional Rich-style features:

Feature print() IceCream LitPrinter
Shows variable names
Syntax highlighting
Rich-style panels
Pretty tracebacks
Configurable colors
Enable/disable toggle

⚡ Quick Start

pip install litprinter
from litprinter import ic

x = 42
ic(x)  # Output: ic| x: 42

That's it! LitPrinter automatically shows both the variable name and its value with beautiful syntax highlighting.

🎯 IceCream-Compatible API

LitPrinter is fully compatible with IceCream's API:

from litprinter import ic

# Basic debugging
x, y = 10, 20
ic(x, y)  # ic| x: 10, y: 20

# Works with expressions
ic(x * 2)  # ic| x * 2: 20

# Configure output
ic.configureOutput(prefix='DEBUG| ')
ic.configureOutput(includeContext=True)

# Enable/disable
ic.disable()  # Silent, but still returns values
ic.enable()   # Re-enable output

# Format without printing
s = ic.format(x, y)

🎨 Color Themes

LitPrinter includes multiple color themes:

from litprinter import ic, set_style, SolarizedDark, LitStyle, CyberpunkStyle, MonokaiStyle

# Default is SolarizedDark (IceCream-compatible)
ic(x)

# Switch to vibrant LitStyle
set_style(LitStyle)
ic(x)

# Try neon Cyberpunk
set_style(CyberpunkStyle)
ic(x)

# Classic Monokai
set_style(MonokaiStyle)
ic(x)

Available Themes:

  • SolarizedDark - IceCream-compatible (default)
  • LitStyle - Vibrant and modern
  • CyberpunkStyle - Neon pink, teal, green
  • MonokaiStyle - Classic code editor theme

✨ Features

📊 Smart Object Formatting

data = {
    "users": ["alice", "bob"],
    "settings": {"theme": "dark"}
}
ic(data)  # Formatted with proper indentation and highlighting

🔍 Context-Aware Output

def calculate_total(a, b):
    ic(a, b, includeContext=True)
    # Output: ic| [script.py:3 in calculate_total()] >>> a: 10, b: 20
    return a + b

🧵 Inline Usage

# Use inline - ic() returns the value
result = ic(calculate(x))  # Prints AND returns the value

💥 Beautiful Tracebacks

from litprinter.traceback import install

install(
    theme="cyberpunk",
    show_locals=True,
    extra_lines=3
)

# Now all exceptions show beautiful tracebacks!

🖼️ Rich-Style Panels

from litprinter import Panel, Console

# Create bordered panels
panel = Panel("Hello, World!", title="Greeting")
print(panel)

# Rich-style console
console = Console()
console.print("[bold red]Error:[/bold red] Something went wrong!")

🔧 Configuration

Global Configuration

from litprinter import ic

ic.configureOutput(
    prefix='DEBUG| ',           # Custom prefix
    includeContext=True,        # Show file/line/function
    contextAbsPath=False,       # Use relative paths
    outputFunction=my_logger,   # Custom output function
)

Per-Call Override

ic(x, includeContext=True)  # Override for this call only

Custom Formatters

from litprinter import argumentToString

class MyClass:
    def __init__(self, name):
        self.name = name

@argumentToString.register(MyClass)
def format_myclass(obj):
    return f"MyClass({obj.name})"

ic(MyClass("test"))  # ic| MyClass(test)

🌐 Global Installation

Make ic() available everywhere without imports:

from litprinter.builtins import install

install()

# Now works anywhere!
ic(x)

📦 Migration from IceCream

Just change your import:

# Before
from icecream import ic

# After
from litprinter import ic

All IceCream features work identically, plus you get:

  • Multiple color themes
  • Rich-style panels and console
  • Beautiful tracebacks
  • Panel rendering

📚 API Reference

Main Functions

Function Description
ic(*args) Debug print with variable names
ic.configureOutput(...) Configure output settings
ic.disable() / ic.enable() Toggle output
ic.format(*args) Format without printing
set_style(style) Set color theme

Aliases

Alias Same as
LIT ic
litprint ic
lit ic

Traceback Functions

Function Description
traceback.install(**kwargs) Install pretty tracebacks
traceback.uninstall() Restore default tracebacks
PrettyTraceback(...) Create traceback formatter

🆕 What's New in v0.3.0

  • IceCream-compatible API: Full ic.configureOutput(), ic.disable(), ic.enable() support
  • Multiple color themes: SolarizedDark, LitStyle, CyberpunkStyle, MonokaiStyle
  • Style switching: set_style() to change colors at runtime
  • Rich-style features: Console, Panel, styled text
  • Pretty tracebacks: Frame suppression, max_frames, Rich protocols
  • Dynamic versioning: Version from __init__.py
  • Cleaner codebase: Removed duplicate code, simplified architecture

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for details.


Made with ❤️ by OEvortex

Telegram Instagram LinkedIn Buy Me A Coffee

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

litprinter-0.3.0.tar.gz (88.5 kB view details)

Uploaded Source

Built Distribution

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

litprinter-0.3.0-py3-none-any.whl (100.0 kB view details)

Uploaded Python 3

File details

Details for the file litprinter-0.3.0.tar.gz.

File metadata

  • Download URL: litprinter-0.3.0.tar.gz
  • Upload date:
  • Size: 88.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for litprinter-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eb1bce330dc80b412fa85c16d9372bfdca49af0e4247ad091cb2e43bec48b8d4
MD5 5a78d9fecb7bf403d38a4ebbeefe7c3d
BLAKE2b-256 7e917f27b13145471afe0acf750dbe792874198799a5ef484c0bc8338ec26ed4

See more details on using hashes here.

File details

Details for the file litprinter-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: litprinter-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 100.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for litprinter-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4c98fc70192b7570d565af8ea5d0c8ecd2c11a92e65ec353e33f736b801da6
MD5 064b625ccda58659edc030a775d48d62
BLAKE2b-256 8ac6b4b49871551d200d9da9ced89ad70ac356018c3f083d567a21504bbdaad1

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