From 841d71bd7325ce598b55beda2195b552e6b8f05b 2007-06-14 18:11:13 From: vivainio Date: 2007-06-14 18:11:13 Subject: [PATCH] _ip.load runs init_ipython even if the module already exists --- diff --git a/IPython/ipapi.py b/IPython/ipapi.py index 8c5de5a..ad9e937 100644 --- a/IPython/ipapi.py +++ b/IPython/ipapi.py @@ -183,6 +183,7 @@ class IPApi: # The ipython instance provided self.IP = ip + self.extensions = {} global _recent _recent = self @@ -380,12 +381,18 @@ class IPApi: self.IP.rl_next_input = s def load(self, mod): - if mod in sys.modules: - return + if mod in self.extensions: + # just to make sure we don't init it twice + # note that if you 'load' a module that has already been + # imported, init_ipython gets run anyway + + return self.extensions[mod] __import__(mod) m = sys.modules[mod] if hasattr(m,'init_ipython'): m.init_ipython(self) + self.extensions[mod] = m + return m def launch_new_instance(user_ns = None):