質問

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