在Python中,是否有可能在没有范围的情况下运行一些代码?
我最喜欢的调试工具之一是启动控制台的简短代码。 但是,我有时会通过(大致)调试
try:
#my code
...
except:
launch_console()
,这需要预测错误的位置。如果我将整个脚本包装在尝试/除外,则我将无法访问我正在调试的函数中的任何变量。
如果我可以运行该程序,并且只需在错误的情况下运行在不丢失范围的情况下运行,那将非常方便。我认为Spyder应该具有此功能,但它不起作用。
想知道是否有一些不错的方法!
One of my favorite debug tools is a short piece of code which starts up a console. I sometimes debug by means of (roughly)
try:
#my code
...
except:
launch_console()
However, this requires anticipating where the error will be. If I enclose the entire script in a try/except, I will not have access to any variables within the function I am debugging.
It would be magnificently convenient, if I could run the program and just automatically have launch_console()
run in case of an error, without losing scope. I think spyder is supposed to have this functionality, but it does not work.
Wondering if there is some nice way to do this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论