Any way to turn off exception handling? (debugging)

mk mrkafk at gmail.com
Thu Feb 11 12:32:55 EST 2010


Simon Brunning wrote:
> Not as far as I know. Besides, the chances are that if you were to be
> able to turn off exception handling altogether your code wouldn't make
> it as far as the code you are interested in anyway.

Sure, but I could deal with that, jerry-rigging the code as exceptions 
go by, finally reaching the exception I care about.

With all the problems, this would still be much better than nothing. As 
thing are, the only way to do this is guessing and turning particular 
try / except blocks off.

(a really nifty solution would be turning exceptions on or off per 
module / file basis).

IIRC Lua and/or C++ do have this ability, why not Python?

I smell material for a PEP.

> Is there some way you could monkey patch the exception class to add
> some logging in there or something?

Sure I can, but how do I get out of Python the info *what called 
particular class/instance*? That is, how do I know who's the caller?

Regards,
mk




More information about the Python-list mailing list