I am invoking the python interpreter like the following
python -m MyModule.main
Is there an easy way to invoke the the pdb debugger via the command line in this use case ?
I am invoking the python interpreter like the following
python -m MyModule.main
Is there an easy way to invoke the the pdb debugger via the command line in this use case ?
You can execute pdb on a python file which has same effect as executing python -m MyModule.main
using the runpy module (see https://www.python.org/dev/peps/pep-0338/#id16) e.g as a command on a UNIX-like OS:
python -m pdb <(echo "import runpy;runpy.run_module('MyModule.main', run_name='__main__', alter_sys=True)")
This could be generalised into a function that you could add to your bash_profile:
function pdb-m {
python -m pdb <(echo "import runpy;runpy.run_module('$1', run_name='__main__', alter_sys=True)") "${@:2}"
}