I am using Python 2.7.6 and IDLE in Windows 8. I am doing the following: import count, then modify something in count, then reload(count), and the changes are not updated. What am I doing wrong?

Thanks!

有帮助吗?

解决方案

In python, when you reload a module, any old references to the module or anything from the module are not affected.

If you look at the documentation for reload, you'll see this:

Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is desired.

So if you reload a module, you need to recreate any objects from that module in order to get the changes from the reload.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top