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
Building on @jed's answer, I built this module:
import pdb
import runpy
import sys
def main():
module = sys.argv[1]
sys.argv[1:] = sys.argv[2:]
pdb.runcall(runpy.run_module, module, run_name='__main__')
__name__ == '__main__' and main()
Put that module as mpdb.py
anywhere in your Python Path (current directory works), then you may invoke:
python -m mpdb somepackage.somemodule even with args