Skipping instructions during an interactive python debugging session

I was wondering if it is possible to skip a command during an interactive debugging session. Suppose I am debugging the following code

action_1()
time.sleep(60)
action_2()

      

If I'm in action_1()

, I need to wait a minute to get to action_2()

. I would like the debugger to be able to skip the next statement without executing it. I tried googling it but nothing useful came up.

Quick and dirty workarounds can be found, such as commenting out the sleep statement or wrapping it with an if statement, but they are cumbersome and error prone. I am looking for a more elegant solution.

+3


source to share


1 answer


I believe you want the go to PDB command :



j (ump) lineno

Set the next line to be executed. Only available in the lowest frame. This allows you to go back and execute the code again, or go forward to skip code you don't want to run.

It should be noted that not all jumps are valid - for example, it is impossible to jump to the middle of a for loop or from the final clause.

+4


source







All Articles