【发布时间】:2010-12-01 21:42:29
【问题描述】:
我有一些处理异常的代码,并且我只想在它是特定异常时执行特定的操作,并且只能在调试模式下执行。比如:
try:
stuff()
except Exception as e:
if _debug and e is KeyboardInterrupt:
sys.exit()
logging.exception("Normal handling")
因此,我不想只添加:
except KeyboardInterrupt:
sys.exit()
因为我试图将调试代码中的差异保持在最小程度
【问题讨论】:
标签: python exception exception-handling