less than 1 minute read

icecream

If you find yourself adding print statements to help you debug:

print('input:', input)
output=some_function(input)
print('output', output)

Library IceCream aims to make this a simplier task.

As described in their documentation: ic() is like print(), but better:

  1. It prints both expressions/variable names and their values.
  2. It’s 60% faster to type.
  3. Data structures are pretty printed.
  4. Output is syntax highlighted.
  5. It optionally includes program context: filename, line number, and parent function.

Using IceCream, the above statements would be:

from icecream import ic
ic(input)
output=some_function(input)
ic(output)

and would yield:

ic| input: 'hello world'
ic| foo(123): 'some result'

More examples can be found on the IceCream site

PyPi