Daily Dose of Data Science

Share this post

Don't use print() to debug your code.

www.blog.dailydoseofds.com

Don't use print() to debug your code.

Avi Chawla
Oct 9, 2022
3
Share

Debugging with print statements is a messy and inelegant approach. It is confusing to map the output to its corresponding debug statement. Moreover, it requires extra manual formatting to comprehend the output.

The "icecream" library in Python is an excellent alternative to this. It makes debugging effortless and readable, with minimal code. Features include printing expressions, variable names, function names, line numbers, filenames, and many more.

P.S. The snippet only gives a brief demonstration. However, the actual functionalities are much more powerful and elegant as compared to debugging with print().

More about icecream here: https://github.com/gruns/icecream.

Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.

3
Share
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Avi Chawla
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing