Default is SolarizedDark (IceCream-compatible)
December 7, 2025 ยท View on GitHub
๐ฅ 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.