Vulcan
Vulcan

Reputation: 183

Python debugging: is there a tool that lets you enter a function when an exception happens (just like a breakpoint)?

For example, in R you can set options(error = recover), and whenever an error occurs, it will let you inspect all the functions that are active at the time along with all the variables in their scope. It's basically like retroactively inserting a breakpoint wherever an error occurs.

Does pdb or Python have a tool like this?

Upvotes: 0

Views: 73

Answers (1)

Rishaan Gupta
Rishaan Gupta

Reputation: 563

If you are using VS Code as your editor, you should be able to do this.

Simply click Run > Start Debugging, and select a debug configuration


Screenshot of me using a variable that does not exist:

enter image description here

Upvotes: 1

Related Questions