Postmortem Debugging in Python

serhatteker

Serhat Teker

Posted on June 23, 2021

Postmortem Debugging in Python

If you'd like to debug your code if only it throws an uncaught exception run:

$ python -m ipdb your_program.py
Enter fullscreen mode Exit fullscreen mode

INFO
You can use default debugger — pdb, but I prefer ipdb.

Install it with: pip install ipdb

If you don't provide the -c continue flag then you'll need to enter 'c' —continue, when execution begins. So it's better to use it with the flag:

$ python -m ipdb -c continue your_program.py
Enter fullscreen mode Exit fullscreen mode

And since I use it a lot, I got an alias for it:

alias pd='python -m ipdb -c continue'
Enter fullscreen mode Exit fullscreen mode

All done!

💖 💪 🙅 🚩
serhatteker
Serhat Teker

Posted on June 23, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related