Вопрос

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