Since Python 3.7 we have breakpoint() as a way of replacing the traditional import pdb; pdb.set_trace().
But if we use another third party library as pudb, ipdb, rpdb, we can not use it.
PYTHONBREAKPOINT environment variable can be set to the name of a callable.
The way of using that environment variable is easy as exporting it:
export PYTHONBREAKPOINT=ipdb.set_trace # or export PYTHONBREAKPOINT=pudb.set_trace export PYTHONBREAKPOINT=wdb.set_trace # if we don't want to set the env we can also do: PYTHONBREAKPOINT=ipdb.set_trace python3 main.py
If you want to add more context to the code that you are debugging (if you want to see more lines) you can do
ipdb.set_trace(context=21) # or breakpoint(context=21)