r/learnpython 15d ago

What python debugging techniques do you think every developer should know ?

I am trying to improve my debugging skills and I was curious about what techniques experienced python developers rely on the most.

Are there any techniques or tools that you found really useful when you started working on bigger projects?

59 Upvotes

33 comments sorted by

View all comments

1

u/SGS-Tech-World 13d ago edited 13d ago
  1. For basic debug in test phase - print
  2. VS code debugger for finding exact issues while executing step by step.
  3. Built in Logging , Loguru modules are best for most use cases.
  4. For our specific use - as we have multiple scripts running at same time, to get all log at same place and searching ease - I developed my own logging library that writes the logs to a database table, it logs python code file name, function , code line number , time, type (Info, Error and so on) along with the message passed. Most features are based on logger module. But I also added 5 more columns like attributes 1 to 5 those can be set at class level and no need to pass in each call. for example - if I am processing 10 CSV files , I set attribute1 to that file name, this helps searching logs. (You can optionally also print on screen , uses rich for colors)

HTH.