IDLE - 重新编译更改的代码

发布于 2025-01-06 09:13:41 字数 121 浏览 3 评论 0原文

我似乎无法强制 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼趣 2025-01-13 09:13:41

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.

药祭#氼 2025-01-13 09:13:41

您必须手动强制保存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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文