gruns / icecream

🍦 Never use print() to debug again.
MIT License
9.21k stars 187 forks source link

A tiny tip for jupyter notebook #189

Closed 3DAlgoLab closed 2 months ago

3DAlgoLab commented 2 months ago

I am not sure if this is a valuable tip, but I found it quite useful, so I am writing this with some courage. When you call ic(...) at the end of a Jupyter notebook cell, it repeats as shown below. This can sometimes cause confusion. Therefore, if you assign the last ic to a dummy variable (_), it will not repeat. Here is an example:

from icecream import ic 
a, b,c = [1, 2, 3]
ic(a, b, c)

output:

ic| a: 1, b: 2, c: 3
(1, 2, 3)

Subtle Tip

from icecream import ic 
a, b,c = [1, 2, 3]
_=ic(a, b, c)

output:

ic| a: 1, b: 2, c: 3