The most sophisticated debug printing library for Python - IceCream + Rich fusion with syntax highlighting and beautiful tracebacks
Project description
🔥 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.
🚀 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 modernCyberpunkStyle- Neon pink, teal, greenMonokaiStyle- 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litprinter-0.3.1.tar.gz.
File metadata
- Download URL: litprinter-0.3.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4eccd14ff5030d1914cc94c922c21bb4315832d65a94f0a496837baed584e400
|
|
| MD5 |
5e2884f8ae0c0b5bfd31d1f6f66d0c07
|
|
| BLAKE2b-256 |
9ded63aae52a6b10d837c7fbcd4f6964e65ac9d68f003a33b75353eb6ee50e3d
|
File details
Details for the file litprinter-0.3.1-py3-none-any.whl.
File metadata
- Download URL: litprinter-0.3.1-py3-none-any.whl
- Upload date:
- Size: 99.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c71d5a69c7b3fae1a19d33c4bea84157ab474de6f50a1d1b9175c0519a8c20fa
|
|
| MD5 |
e479726df73d20e0a41b61a720373c12
|
|
| BLAKE2b-256 |
54fd2a6596b12111a8c595e1ed1d05ebf89ebe09c845f332d110c8fa82843126
|