At the top of my Python scripts I have defined the following convenience function for debugging with ipdb:
def bp():
import ipdb
ipdb.set_trace()
So when I want to debug in a certain point I can write:
bp()
instead of having to write
import ipdb; ipdb.set_trace()
(I prefer not to import ipdb unless needed).
The problem with this approach is that when entering pdb I land inside the function bp(), so I have to press 'u' to go to the relevant part of the code:
> /path/to/script.py(15)bp()
14 import ipdb
---> 15 ipdb.set_trace()
16
ipdb> u
Is there a way I could have a similar approach, but landing directly into the relevant part of the code?