我最近发现了非常有用的“-i”标志的Python如何检查Python引发异常的函数的作用域?
-i : inspect interactively after running script, (also PYTHONINSPECT=x) and force prompts, even if stdin does not appear to be a terminal
这是伟大的,在全球范围内检查对象,但如果异常是在一个函数调用提出会发生什么,我是否想检查函数的局部变量?当然,我对第一次提出例外的范围感兴趣,有什么办法可以达到它?
检查这个问题:[自动启动python调试器出错](http://stackoverflow.com/questions/242485/starting-python-debugger-automatically-on-error) – tzot 2009-05-25 13:41:33
谢谢,但这并不完全是我寻找。如果可能的话,我不希望包装代码。 – saffsd 2009-05-25 13:59:15