1 Replies - 394 Views - Last Post: 02 October 2018 - 04:09 AM Rate Topic: -----

#1 bobsmith76   User is offline

  • D.I.C Regular

Reputation: 11
  • View blog
  • Posts: 323
  • Joined: 14-February 17

pdb bugger: stop on error and preserve values of variables

Posted 01 October 2018 - 08:07 PM

Pycharm has this feature and I really love it. When you run your code and an error is thrown, the code stops but you're still able to inspect all of the values of your variables. The pdb debugger is faster than pycharm so if I could figure out how to get this feature in the pdb debugger it would be really great. First, I realize you can do this with try except. But the time it takes you to write the try except statement then delete it when you're done will erase the advantages of the pdb debugger, namely, speed. Looking at the documentation there are some things which might point to what I want but because the official documentation assumes roughly 5 years of experience I cannot exactly tell if it is what I want. These are the passage I'm referring to:



Enter post-mortem debugging of the given traceback object. If no traceback is given, it uses the one of the exception that is currently being handled (an exception must be being handled if the default is to be used).

Also, let me be clear that I am not interested in just using simple breakpoints. What I want is to run my code and then if an unexpected error is thrown I want to not have to restart the debugger but want to be able to view the values of the variables as is.

Is This A Good Question/Topic? 0
  • +

Replies To: pdb bugger: stop on error and preserve values of variables

#2 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 463
  • View blog
  • Posts: 1,468
  • Joined: 27-December 13

Re: pdb bugger: stop on error and preserve values of variables

Posted 02 October 2018 - 04:09 AM

Running python in the very mundane IDLE environment makes it possible to inspect variables after a code stop due to errors - provided that the variables are in the main part of the code.
Variables in separate scopes are not available for inspection.

In order to get similar data from functions, methods etc. without custom writing and placing of try/except blocks; maybe write a generic decorator that you can use when relevant.

Hm, I think a small decorator tutorial can be made here...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1