MCPcopy Create free account
hub / github.com/ipython/ipython / reload_extension

Method reload_extension

IPython/core/extensions.py:112–130  ·  view source on GitHub ↗

Reload an IPython extension by calling reload. If the module has not been loaded before, :meth:`InteractiveShell.load_extension` is called. Otherwise :func:`reload` is called and then the :func:`load_ipython_extension` function of the module, if it exists is called.

(self, module_str)

Source from the content-addressed store, hash-verified

110 return "no unload function"
111
112 def reload_extension(self, module_str):
113 """Reload an IPython extension by calling reload.
114
115 If the module has not been loaded before,
116 :meth:`InteractiveShell.load_extension` is called. Otherwise
117 :func:`reload` is called and then the :func:`load_ipython_extension`
118 function of the module, if it exists is called.
119 """
120 from IPython.utils.syspathcontext import prepended_to_syspath
121
122 if (module_str in self.loaded) and (module_str in sys.modules):
123 self.unload_extension(module_str)
124 mod = sys.modules[module_str]
125 with prepended_to_syspath(self.ipython_extension_dir):
126 reload(mod)
127 if self._call_load_ipython_extension(mod):
128 self.loaded.add(module_str)
129 else:
130 self.load_extension(module_str)
131
132 def _call_load_ipython_extension(self, mod):
133 if hasattr(mod, 'load_ipython_extension'):

Callers 3

test_extension_loadingFunction · 0.80
reload_extMethod · 0.80
test_autorestoreFunction · 0.80

Calls 6

unload_extensionMethod · 0.95
load_extensionMethod · 0.95
reloadFunction · 0.85
addMethod · 0.45

Tested by 2

test_extension_loadingFunction · 0.64
test_autorestoreFunction · 0.64