0

Hi,
I was wondering how to debug python script without adding pdb module to the script file. Say, I have a script test.py without adding "import pdb" and "pdb.set_trace()". Can I debug it in Python running in terminal by importing pdb there? How to set up breakpoints and start the debugging. I tried it this way in Python running in the terminal:

import pdb
    pdb.break test.py: 9
    pdb.run('test.py')

But there will be an error

File "<stdin>", line 1
pdb.break test.py: 9
^
SyntaxError: invalid syntax

I know I am wrong. Please tell me how to do correctly. Really appreciate your help!

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Outdoor83
0

Easiest way is to run it in your debugger of choice on the command-line. Since yours seems to be pdb (a pretty bad choice, really... it doesn't do very useful things like threaded debugging), try the following:

pdb script_name.py argument1 argument2 ...

It should dump you into a debugger on the first line of your code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.