Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Debugging Using Pdb

I'm using a interactive graphical Python debugger with ipdb under the hood (Canopy's graphical debugger). The script I am working on has multiple imported modules and several calls to their respective functions. Whenever I attempt a debugging run, execution gets stuck somewhere within a call to an imported module's function (specifically subprocess). My two main questions are:

1) Does running in debug mode slow things down considerably? Is the code not actually stuck, but just running at a painfully slow rate?

2) Is there a way to completely pass over bits of code and run them as if I were not even debugging? I want to prevent the debugger from diving into subprocess and just execute it as if it were a normal run.

I might toss the graphical debugger and do everything from a terminal, but I would like to avoid that if I can because the graphical interface is really convenient and saves a lot of typing.

like image 774
Mr. Frobenius Avatar asked Nov 09 '22 18:11

Mr. Frobenius


1 Answers

import pdb
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = a + b + c
print final

Your output when you run the code then it will start debugging and control will stop after a="aaa"

$ python abc.py
(Pdb) p a
'aaa'
(Pdb)

Thanks, Shashi

like image 123
Shashikant Vasudev Pattar Avatar answered Nov 14 '22 21:11

Shashikant Vasudev Pattar