Skip to content

Instantly share code, notes, and snippets.

@aleneum
Created November 1, 2016 10:59
Show Gist options
  • Save aleneum/3f92684e3395bde2d7f99b57938563c9 to your computer and use it in GitHub Desktop.
Save aleneum/3f92684e3395bde2d7f99b57938563c9 to your computer and use it in GitHub Desktop.
Unloads all module related imports from current python session
# unloads all imports from a certain module
def unload_module(name):
dk = []
for k in sys.modules.keys():
if k.startswith(name):
dk.append(k)
for k in dk:
del sys.modules[k]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment