1

Is there a way to invoke a python program such that it will run normally if it does not die, but if it has an uncaught exception, to behave as though it were run with -i?

The reason is that I am running my python program from an external script, and it does not encounter the exceptional condition until several runs in. So I want to just lazily go into interactive mode so I can then load up the debug module and look at the postmortem to see the stack variables, but not to have it fall into the interactive prompt for all the earlier runs of the program which do succeed.

4

1 回答 1

3

Stuff a function into sys.excepthook that creates a console using code.

于 2013-06-11T00:48:44.093 回答