Python: "de-import", "re-import", "reset import"?

Viewed 3936

I debug (in PyCharm) a script. I stop at a breakpoint, then I go to the debug console window and from there, I invoke an import line, like this:

import my_util1 from my_utils

Then I call my_util1. So far, everything is OK. Then I change something in "my_util1". Now I would like to call the (updated) my_util1 but I cannot: the system (Python? Pycharm?) "sees" only the previous version of my_util1.

Is there a possibility to "reset" (refresh) what I imported earlier, or to "re-import" it, other than exiting PyCharm and restarting the project?

It is not about dynamically changing the actual code that is being debugged. The task that I am looking for is simpler - it would suffice just to undo an 'import' operation, or to reset/clear/refresh all 'imports' at once. Additionally, the action could be done within the debugger window, not in the code window.

1 Answers
Related