r/pythontips • • Mar 24 '21

Python3_Specific How to debug in Python?

Please share some tips about the title.

32 Upvotes

38 comments sorted by

View all comments

6

u/miamiredo Mar 25 '21

Really surprised no one mentioned:

import pdb

pdb.set_trace()

I put that anywhere I want to inspect what is going on and run the script! Then you can see what variables are at that point and also go through the code line by line!

2

u/mutatedllama Mar 25 '21

Yeah this is usually step 1 for me!