IDLE - 重新编译更改的代码
我似乎无法强制 IDLE 重新编译代码。这是我的简单设计:
类A和B,B导入A
当我更改A,然后运行B时,IDLE似乎没有重新编译A并运行旧版本的A。
我该如何解决这个问题? :\
I can't seem to force IDLE to recompile code. Here's my simple design:
class A and B, B imports A
When I change A, then run B, IDLE doesn't seem to recompile A and run the old version of A.
How can I fix this? :\
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
python 跟踪器 上的答案是有人使用带有启动属性
/usr 的图标启动 IDLE /bin/idle-python2.5 -n
。关键问题是-n
的存在,它表示在 IDLE 进程中运行用户代码。因此,当 B 在第一次运行后导入 A 时,A 位于 IDLE 进程的 sys.modules 中。如果没有-n
,IDLE 将在新的独立进程中的编辑器 (F5) 中运行用户代码,其中 A 必须从文件中重新导入。金显然也有同样的问题。The answer on the python tracker was that someone was starting IDLE with a icon with startup property
/usr/bin/idle-python2.5 -n
. The key issue is the presence of-n
, which says to run user code in the IDLE process. So when B imported A after the first run, A was in sys.modules of the IDLE process. Without-n
, IDLE runs user code in the editor (F5) in a new, separate process, where A has to be re-imported from the file. Jin apparently had the same issue.您必须手动强制保存A (CTRL+S)
然后运行B(这也会提示你保存B)
IF A 自上次以来发生了变化,应该重新编译。
You have to manually force save on A (CTRL+S)
And then run B (this will prompt you to save B too)
IF A has changed since last time it should recompile.