4 ms·
Reload only reloads one copy of the module. If there are other modules that imported the same module, your new definition will not be seen by them unless you f
by oalae5niMiel7qu 3y ago
Reload only reloads one copy of the module. If there are other modules that imported the same module, your new definition will not be seen by them unless you find all the copies of foo in memory and reload them also. Since there's no reliable way to do that, you're more likely to just restart Python all the time.
- gilch 3y agoNot accurate as worded. Python caches module imports in `sys.modules`, so all imports get the same one. A `reload()` will reuse the same dict object that was being used as the module's namespace, so everything with a reference to the module object will see the same namespace and get the updates.