为什么我的修改源文件在调试时没有生效? [英] Why my modification of source file doesn't take effect when debugging?

查看:80
本文介绍了为什么我的修改源文件在调试时没有生效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows版本的Python和IDLE。当我调试我的.py

文件时,我对.py文件的修改似乎没有生效

除非我重新启动IDLE。保存文件并重新导入它也没有帮助


。哪里有问题?


谢谢。

I''m using the Windows version of Python and IDLE. When I debug my .py
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn''t help

either. Where''s the problem?

Thanks.

推荐答案

sandorf写道:
sandorf wrote:
我正在使用Windows版本的Python和IDLE。当我调试.py
文件时,我对.py文件的修改似乎没有生效
除非我重新启动IDLE。保存文件并重新导入它也没有帮助

。哪里有问题?

谢谢。
I''m using the Windows version of Python and IDLE. When I debug my .py
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn''t help

either. Where''s the problem?

Thanks.



没问题。只需重新加载()它。

- jmj


No problem. Just reload() it.
- jmj


>我正在使用Windows版本的Python和IDLE。当我调试.py
> I''m using the Windows version of Python and IDLE. When I debug my .py
文件时,我对.py文件的修改似乎没有生效
除非我重新启动IDLE。保存文件并重新导入它也无济于事。问题出在哪里?
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn''t help
either. Where''s the problem?




" import"只在第一次调用时才读取文件。每次导入

之后调用内存中的模块。这是为了防止模块之间的循环依赖关系创建无限循环。

你需要使用reload()函数:



"import" only reads the file the first time it''s called. Every import
call after that looks up the module in memory. This is to prevent
circular dependencies between modules from creating infinite loops.
You need to use the reload() function:

import foo


#change foo的内容

foo = reload(foo) )
import foo
#change the contents of foo
foo = reload(foo)






infidelaécrit:
infidel a écrit :
我正在使用Windows版本的Python和IDLE。当我调试.py
文件时,我对.py文件的修改似乎没有生效
除非我重新启动IDLE。保存文件并重新导入它也无济于事。问题出在哪里?
I''m using the Windows version of Python and IDLE. When I debug my .py
file, my modification to the .py file does not seem to take effect
unless I restart IDLE. Saving the file and re-importing it doesn''t help
either. Where''s the problem?



" import"只在第一次调用时才读取文件。每次导入后都会调用内存中的模块。这是为了防止模块之间的循环依赖关系创建无限循环。
你需要使用reload()函数:


"import" only reads the file the first time it''s called. Every import
call after that looks up the module in memory. This is to prevent
circular dependencies between modules from creating infinite loops.
You need to use the reload() function:




事实上,如果掉落这个愚蠢的行为,那将会有很大的帮助。我确定我不是唯一一个因为那个错误而浪费了大量时间的人。是的我称之为bug。



As a matter of fact, it would help a lot if that stupid behaviour of
Idle was dropped. I''m sure I''m not the only one who lost lots of time
because of that bug. Yes I call it a bug.


这篇关于为什么我的修改源文件在调试时没有生效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆