Debugging Python Code¶
To my knowledge there are two main approaches to debugging some Python code in Emacs.
Using M-x pdb¶
Emacs supports Python’s built-in pdb debugger out of the box thanks to the Grand Unified Debugger.
Since everything is avaialable out of the box, there’s nothing really to setup!
Just run M-x pdb, Emacs will ask you how you want to invoke pdb
Run pdb (like this): python -m pdb
Which you can of course modify to run your code.
What’s cool about this is that it can be any python command that eventually results in a pdb session.
For example, I often will pass the --pdb flag to pytest to conduct a post-mortem on a particular test case, this will just workTM with Emacs’ pdb command!
Run pdb (like this): hatch test -i py=3.11 -i sphinx=8 -- tests/example/test_example.py::test_this --pdb
Breakpoints can be added by adding a call to the built-in breakpoint() function.
Using dape¶
TODO
Figure out how to use this.