Repolode
gruns

gruns/icecream

A Python debugging helper where ic() replaces print() by showing variable names, expressions, and their values with pretty-printed, syntax-highlighted output.

Stars
10,109
Forks
235
Open issues
77
Last commit
2 days ago

What is it?

IceCream is a Python debugging library built around a function called ic(), which is a more convenient replacement for print(). When given a variable or expression, ic() prints the source text alongside the computed value, so you can see what was passed without writing the label by hand. Data structures are pretty-printed and the output is syntax highlighted.

Called with no arguments, ic() reports the calling filename, line number, and parent function, which makes it useful for tracing which branches of code actually run and in what order. ic() also returns its arguments, so it can be wrapped around existing expressions without changing behavior, and ic.disable() and ic.enable() turn all output on or off at once.

The output format, prefix, destination, and value serialization can be customized through configureOutput, including registering custom formatters for specific types. The library supports Python 3 and PyPy3, and ic.format() returns the output as a string for use with logging.

Key features

  • 01Prints both the source expression and its value for variables and expressions.
  • 02Pretty-prints data structures with syntax highlighting.
  • 03Without arguments, reports the calling file, line number, and parent function.
  • 04Returns its arguments so it can be inserted into existing code.
  • 05Can be globally disabled and re-enabled, and installed into builtins.
  • 06Output prefix, destination, and value formatting are configurable.

Use cases

  • Quickly inspecting variable values while debugging a Python script.
  • Tracing which branches or functions execute and in what order.
  • Routing debug output into a logger via ic.format().
  • Leaving debug calls in code and silencing them in production with disable().

Quick start

  1. 1

    Install IceCream with pip

    pip install icecream
  2. 2

    Import ic and call it on a variable or expression to print its name and value

Topics

FAQ

What is icecream?
A Python debugging helper where ic() replaces print() by showing variable names, expressions, and their values with pretty-printed, syntax-highlighted output. IceCream is a Python debugging library built around a function called ic(), which is a more convenient replacement for print(). When given a variable or expression, ic() prints the source text alongside the computed value, so you can see what was passed without writing the label by hand. Data structures are pretty-printed and the output is syntax highlighted.
Is icecream free to use? What license does it have?
icecream is open source under the MIT license. Check the license terms before using it in commercial products.
Is icecream still maintained?
Actively maintained. The last commit to icecream was on Oct 19, 2026.
What can I use icecream for?
Quickly inspecting variable values while debugging a Python script. Tracing which branches or functions execute and in what order. Routing debug output into a logger via ic.format(). Leaving debug calls in code and silencing them in production with disable().
How do I install icecream?
Install IceCream with pip: pip install icecream Import ic and call it on a variable or expression to print its name and value
Where can I get icecream?
The source code and installation instructions are on GitHub: https://github.com/gruns/icecream

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects