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"

Share:
12,339

Related videos on Youtube

Admin
Author by

Admin

Updated on June 09, 2021

Comments

  • Admin
    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?