How do you pass script arguments to pdb (Python)?

Glenn picture Glenn · May 16, 2009 · Viewed 11.2k times · Source

I've got python script (ala #! /usr/bin/python) and I want to debug it with pdb. How can I pass arguments to the script?

I have a python script and would like to debug it with pdb. Is there a way that I can pass arguments to the scripts?

Answer

Ayman Hourieh picture Ayman Hourieh · May 16, 2009
python -m pdb myscript.py arg1 arg2 ...

This invokes pdb as a script to debug another script. You can pass command-line arguments after the script name. See the pdb doc page for more details.