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

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!

The simpliest way would be using and IDE, like Idle, that has debugging built in.

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.