JohnnyS
JohnnyS

Reputation: 191

How to implement a try/except with the same result as a keyboardinterrupt?

I want to exit the program at a specific position (except statement) for debugging. Further, I want to be able to stay in the console and play with the variables and objects (DataFrames) which have been defined so far by the program. Just as when hitting strg*c, but at a position I can control more precisely.

sys.exit() will also shut down the console and all objects are "lost?

Upvotes: 0

Views: 49

Answers (1)

itzMEonTV
itzMEonTV

Reputation: 20339

You can use debugger

try:
   #code
except:
   import pdb;pdb.set_trace()

So you will get a shell to debug.

Upvotes: 1

Related Questions