문제

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