Python: importlib.reload, continued

Self-tutoring about Python: the tutor continues about reloading a module.

In my post from July 24, 2021, I mention import importlib, then importlib.reload(moduleA) in Python. This might be done if you’ve changed moduleA.

In my experience, if you tried to import the module but the repl complained, it likely didn’t import. In such a case, fixing the module, then trying to reload it, seems not to work, likely since it didn’t import before. Instead, just using import seems to work, provided the module is fixed.

The point is that, in my experience, importlib.reload(moduleA) only works if moduleA was successfully imported already.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply