0

Is there a way to skip for and while loops while debugging Python code in VS Code? I have to call a method that iterates through a 2D array before I get to where I actually want to debug, so it's kind of annoying to have to do that each time I try to debug.

1
  • 3
    set a breakpoint after the loop and then F5 Commented Jul 7, 2023 at 23:04

2 Answers 2

2

Set a breakpoint after the line that needs to be skipped. You can also edit breakpoints and enter expressions to skip them.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

If supported by your extension's debugger contribution, you could put your cursor at the line you want to "skip to", and then use the "run to cursor" item of the context menu. Python supports this. See also How to use the "jump to cursor" debugger command when debugging Python in Visual Studio Code.

If you have no breakpoints in the loop body that would interfere with this, you could also just put a breakpoint where you want to "skip to", and let execution break there. If you do have breakpoints in the loop body that would interfere with this, you could temporarily disable those breakpoints (see their context menu). Perhaps you might also find conditional breakpoints useful for that, but I doubt it (check out VSCode debugger conditional breakpoints).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.