def do_python(self, arg):
        """
        # - spawn a python interpreter
        python - spawn a python interpreter
        # <statement> - execute a single python statement
        python <statement> - execute a single python statement
        """
        if self.cmdprefix:
            raise CmdError("prefix not allowed")

        # When given a Python statement, execute it directly.
        if arg:
            try:
                compat.exec_(arg, globals(), locals())
            except Exception:
                traceback.print_exc()

        # When no statement is given, spawn a Python interpreter.
        else:
            try:
                self._spawn_python_shell(arg)
            except Exception:
                e = sys.exc_info()[1]
                raise CmdError(
                    "unhandled exception when running Python console: %s" % e)
def do_python ( self , arg ) : if self . cmdprefix : raise CmdError ( "prefix not allowed" ) if arg : try : compat . exec_ ( arg , globals ( ) , locals ( ) ) except Exception : traceback . print_exc ( ) else : try : self . _spawn_python_shell ( arg ) except Exception : e = sys . exc_info ( ) [ 1 ] raise CmdError ( "unhandled exception when running Python console: %s" % e )
# - spawn a python interpreter
        python - spawn a python interpreter
        # <statement> - execute a single python statement
        python <statement> - execute a single python statement