Enable/Disable icecream module
With ic.disable() and ic.enable(), respectively, the output of ic() can be completely turned off and then turned back on.
Python3
# Python program to enable/disable ic() from icecream import ic ic.disable() ic( 1990 ) ic( "Hello World" ) ic.enable() ic( "GFG" ) ic( 2008 ) |
Output:
$ python gfg.py ic| 'GFG' ic| 2008
Note: Here lines ic(1990) and ic(“Hello World”) are not getting printed.
Debugging with ice cream in Python
Do you often use Python print() to debug your code? However, if you want to make a significant improvement, you could use IceCream which would make debugging faster, cleaner, and easier to read. ic(), which is short for IceCream prints both expressions/variable names and their values. ic() is faster to type than print(). The output is highlighted and printed in a structured format. If you want, you can include program context (filename, line number, and parent function) easily. You could effortlessly debug while solving competitive code problems and save a lot of time while debugging.
Contact Us