#EANF#
When developing a Python package, it's very convenient to use the -m
option to run modules inside the package as scripts for quick testing. For
example, for somepackage with module somemodule.py inside it, invoking
python -m somepackage.somemodule
from the directory where somepackage resides will run somemodule.py as
though the submodule were __main__. Using this calling syntax is
especially important if the package is using explicit relative imports as
described here.
Similarly, it is also convenient to use the -m option to debug a script,
as in
python -m pdb somescript.py
Is there any way to do both at the same time? That is, can I call a module
as though it were a script and simultaneously launch into the debugger? I
realize I can go into the code itself and insert import pdb;
pdb.set_trace() where I want to break, but I'm trying to avoid that.
No comments:
Post a Comment