Hi I'm looking to create a nested interpreter in Python using the Cmd module.
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).
My nested interpreter is currently setup like this:
def instantiateConsole(base):
class SubConsole(cmd.Cmd, base):
def __init__(self):
cmd.Cmd.__init__(self)
def do_action(self,args):
print "Action"
return SubConsole
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.
Is there any workaround to this?