Komodo - 在程序暂停时观察变量并执行代码
通过 Visual Studio IDE 中的 C#,我可以随时暂停程序并观察其变量,检查我想要的任何内容。我注意到,使用 Komodo IDE,当出现崩溃并停止程序流程时,我可以执行完全相同的操作。但由于某种原因,似乎当我尝试在手动暂停程序时执行相同的操作时,无法实现相同的效果。我做错了什么或者这是不可能的吗?在后一种情况下,有人愿意解释我为什么吗?是IDE相关还是Python相关?
谢谢
编辑:其他问题,我怎样才能继续该程序?据我所知,在我调用 code.interact(local = locals()) 后,它的行为就像程序仍在运行一样,所以我无法单击“运行”按钮,只能单击“暂停”或“关闭”。
With c# in the Visual Studio IDE I can pause at anytime a program and watch its variables, inspect whatever I want. I noticed that with the Komodo IDE when something crashes and it stops the flow of the program, I can do exactly the same. But for some reason, it seems that when I try to do the same when I manually pause the program, the same cannot be achieved. Am I doing something wrong or it just isn't possible? In the later case, could anyone care to explain me why? Is it IDE related or Python related?
Thanks
edit: Other question, how can I then continue the program? From what I see, after I call code.interact(local = locals()), it behaves as the program is still running so I can't click in the "Run" button, only on "Pause" or "Close".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你输入
你的程序,那么你将被转储到 python 解释器。 (参见查看当前正在运行的Python程序的方法)
这与暂停 Komodo 略有不同,但也许您可以使用它来实现相同的目标。
按 Ctrl-d 退出 python 解释器并允许程序继续。
您可以使用回溯模块检查调用堆栈:
例如,这里是一个打印调用堆栈的装饰器:
像这样使用它:
If you put
in your program, then you will be dumped to a python interpreter. (See Method to peek at a Python program running right now)
This is a little different than pausing Komodo, but perhaps you can use it to achieve the same goal.
Pressing Ctrl-d exits the python interpreter and allows your program to resume.
You can inspect the call stack using the traceback module:
For example, here is a decorator which prints the call stack:
Use it like this: