在 IDLE 中重新加载方法或对象
当使用空闲时,我知道如果模块发生这样的变化,您可以重新加载模块:
import foo
reload(foo)
如果我只导入模块的一部分,有没有办法以类似的方式重新加载它?
from foo import bar
when using idle, I know you can reload a module if it's changed like this:
import foo
reload(foo)
if I only import part of a module, is there a way to reload it in a similar matter?
from foo import bar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,
reload
必须重新运行整个模块。请注意,
reload
令人困惑,并且不具备保持一致的能力。最好重新启动解释器。No,
reload
has to re-run the whole module.Note that
reload
is confusing and does not have the ability to be consistent. It's much better to restart the interpreter.不,毕竟您必须导入 foo,然后重新加载(foo)。
No. You'll have to import foo, then reload(foo), after all.
http://docs.python.org/2/library/functions.html#reload
它说:
但是语句不是很清楚。
http://docs.python.org/2/library/functions.html#reload
It says:
But the statements is not very clear.