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
# No import needed! ic is automatically available
x = 42
ic(x)  # Output: ic| x: 42

That's it! After installing, ic() is automatically available in all your Python scripts - no import required!

🎯 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)

🌐 Always Available

After pip install litprinter, ic() is automatically available in all Python scripts - no import needed!

# my_script.py - no import required!
x = 42
ic(x)  # Just works!

If you want to temporarily disable:

from litprinter import uninstall
uninstall()  # Remove ic from builtins

# To re-enable:
from litprinter import install
install()

📦 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.2.tar.gz (89.2 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.2-py3-none-any.whl (100.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litprinter-0.3.2.tar.gz
  • Upload date:
  • Size: 89.2 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.2.tar.gz
Algorithm Hash digest
SHA256 63cb4804188f62b63a1d61cf69bb0f5c354a4e3a0ee27e97040d123382f8299b
MD5 626529b6b478228e34dac0f2ce35dbf4
BLAKE2b-256 f26aa91dd260053146f23bd6c088afb482ae0dffc377f7d91c9cc9afe256c87e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: litprinter-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 100.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 694dd77eb0665b9403b83af5ced61d6c2ac64fb6521a9f2c571a6a86aafbf445
MD5 e2462be343d53adabed4b9862780ee39
BLAKE2b-256 f15c1bdb6886b16165187f234ca578b14584cb3ca8c74055dcf3748fd38184d6

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