How do you pass script arguments to pdb (Python)?
12,339
Solution 1
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.
Solution 2
usually I use ipython
-i
If running code from the command line, become interactive afterwards.
It is often useful to follow this with `--` to treat remaining flags as
script arguments.
ipython --pdb -i -- test.py -a
Solution 3
python3 -m pdb myscript.py -a val
if using argparse with flag "a" and value "val"
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on June 09, 2021Comments
-
Admin about 3 years
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?