def test(request): try: x = mathobjects.sage.var('x') exp = x**2 RHS = mathobjects.parse_sage_exp(mathobjects.sage.diff(exp)) LHS = mathobjects.Diff(mathobjects.parse_sage_exp(exp)) sage_test = mathobjects.Equation(mathobjects.LHS(LHS),mathobjects.RHS(RHS)).get_html() except Exception,e: sage_test = e
def run_code(code,ecmds=list()): try: evald = mathobjects.sage.sage_eval(code) parsd = mathobjects.parse_sage_exp(evald) return parsd except NameError, e: m = str(e).split()[1] code.insert(0,( 'var(%s)\n' % m )) return run_code(code)