'Evaluates code in the same context as this function
Return value is tuple `(success, result)`, success being a boolean and
result being a string representing the return value of eval, or None if
exec was used instead.'

def cmd_eval(self, code):

    try:
        try:
            return (True, str(eval(code)))
        except SyntaxError:
            exec code
            return (True, None)
    except:
        error = traceback.format_exc().strip().split('\n')[(-1)]
        return (False, error)
