Introducing IceCream

 

Introducing IceCream: Never Use Print() To Debug Your Python Code Again






Errors are almost inevitable while programming. In fact, it is rightly said that a programmer spends a significant amount of their time debugging to make their code error-free.

While debugging, using print() statements to understand the flow of the pipeline and spot unexpected behavior is undoubtedly the most widely adopted approach.

However, using print() has numerous caveats, such as:

Print statements are usually intended to display an output to the user. If the programmer uses print() to debug, after debugging is over, the programmer should be cautious of removing only those specific print() statements that were intended for debugging.
Often, during debugging, you may print multiple variables one after the other. In such cases, the programmer has to manually format the output to enhance its readability.

Above, we print two variables. Although here we know that the first variable is var_1 and the second is var_2, as the number of variables increases, it might require you to look back and forth between the code and the output to figure out which output corresponds to which variable.

Post a Comment

0 Comments