icecream (gruns/icecream)

Searching Database…

What is this?IceCream is a Python library for friendlier print debugging: instead of print() you call ic(), which prints each expression together with its value, pretty-printed and syntax highlighted.
How is ic() different from just using print()?print() shows only a value; ic() prints the expression with its value, pretty-prints data structures, and highlights the output. Called with no arguments, it prints the file, line, and parent function to trace execution.
How do I add it to a project?Install it with pip (pip install icecream), then import ic and call ic() wherever you would have typed print().
Do I need anything besides Python installed?Just a Python 3 or PyPy3 interpreter — nothing else to set up, pip handles the installation and its dependencies.
Can I leave ic() calls in code that ships to production?Yes: ic() returns its arguments, so calls in pre-existing code keep working; ic.disable() silences output while calls still return, and a fallback import snippet covers environments where IceCream is not installed.
Is there something like ic() for languages other than Python?Yes. The README lists ports for Dart, Rust, Node.js, C++, C99, PHP, Go, Ruby, Java, R, Lua, Clojure, Bash, SystemVerilog, and GameMaker Language, with the stated goal of an ic() in every language.
How does ic() know the expression text I passed in?It uses the executing library by Alex Mojaki to reliably locate ic() calls in your Python source — that is how the expression itself ends up printed next to its value.
Can ic() output feed into the logging module?Not natively yet: the README suggests using ic.format(), which returns the output as a string, to route debugging through your logger, and asks for feedback on adding built-in log level support.
What are similar projects?debug, loguru, memray, apsw, rich, CustomTkinter, terrio, optuna
Creator
gruns
Size
0.5 MB
Stars
10.1K
Age
8y
Commits · 90 Days