title: Instantiate nested Cmd Interpreter in Python
body: <p>Hi I'm looking to create a nested interpreter in Python using the Cmd module.</p>
  
  <p>I set up a dynamic module loading because I want my project to be easily expandable (i.e. add a new python file into a folder and without changing the main code being able to load it).</p>
  
  <p>My nested interpreter is currently setup like this:</p>
  
  <pre><code>def instantiateConsole(base):
  
      class SubConsole(cmd.Cmd, base):
          def __init__(self):
              cmd.Cmd.__init__(self)
  
          def do_action(self,args):
              print "Action"
      return SubConsole
  </code></pre>
  
  <p>This is necessary because in order to create a nested interpreter I have to pass the MainConsole as a second variable to the SubConsole class. The problem with this is that this way I can only create classes inside this method and I won't be able to add a new console module file that I can load dynamically without having the definition inside this method.</p>
  
  <p>Is there any workaround to this?</p>