def METHOD_NAME(self, code):
    # preserve stdout/stderr
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    sys.stdout = self.handle
    sys.stderr = self.handle
    InteractiveConsole.METHOD_NAME(self, code)
    sys.stdout = oldstdout
    sys.stderr = oldstderr