pdb - Launch Python debugger while simultaneously executing module as script -


when developing python package, it's convenient use -m option run modules inside package scripts quick testing. example, somepackage module somemodule.py inside it, invoking

python -m somepackage.somemodule 

from directory somepackage resides run somemodule.py though submodule __main__. using calling syntax important if package using explicit relative imports described here.

similarly, convenient use -m option debug script, in

python -m pdb somescript.py 

is there way both @ same time? is, can call module though script , simultaneously launch debugger? realize can go code , insert import pdb; pdb.set_trace() want break, i'm trying avoid that.

after experimenting quite time, turns out approach works:

python -c "import runpy; import pdb; pdb.runcall(runpy.run_module, 'somepackage.somemodule', run_name='__main__')" 

for reason, use of pdb.runcall on pdb.run important.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -