From 128cfd5fe3f9e3c16f99292c245bc543c2e4237e 2010-08-19 17:26:29 From: Brian Granger Date: 2010-08-19 17:26:29 Subject: [PATCH] Added additional logic to InteractiveShell.instance(). * Subclasses now know about children instances. * Children do not know about parent instances. --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index fd335d9..485c164 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -268,6 +268,14 @@ class InteractiveShell(Configurable, Magic): """Returns a global InteractiveShell instance.""" if not hasattr(cls, "_instance"): cls._instance = cls(*args, **kwargs) + print cls + print cls._instance + # Now make sure that the instance will also be returned by + # the subclasses instance attribute. + for subclass in cls.mro(): + if issubclass(subclass, InteractiveShell): + print subclass + subclass._instance = cls._instance return cls._instance @classmethod