From b0a60f706b102cbfba561bb4a62ca487a6d73b08 Mon Sep 17 00:00:00 2001 From: lafrite Date: Fri, 17 Jan 2014 14:57:45 +0100 Subject: [PATCH] Render ~work with letters still some bugs --- pymath/expression.py | 13 +++++++++++++ pymath/render.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pymath/expression.py b/pymath/expression.py index fb2809f..e48f460 100644 --- a/pymath/expression.py +++ b/pymath/expression.py @@ -324,7 +324,11 @@ class Expression(object): """ return type(exp) == int or \ type(exp) == Fraction or \ +<<<<<<< HEAD type(exp) == FormalExp +======= + exp.isalpha() +>>>>>>> Render ~work with letters still some bugs @staticmethod def isOperator(exp): @@ -405,6 +409,15 @@ if __name__ == '__main__': #e = Expression(exp) #print(e) + exp="-2*a(12 + 1)(3-12)" + e = Expression(exp) + print(e) + + # TODO: The next one doesn't work |ven. janv. 17 14:56:58 CET 2014 + #exp="-2*(-a)(12 + 1)(3-12)" + #e = Expression(exp) + #print(e) + ## Can't handle it yet!! #exp="-(-2)" #test(exp) diff --git a/pymath/render.py b/pymath/render.py index 1b2dd6f..326224b 100644 --- a/pymath/render.py +++ b/pymath/render.py @@ -15,7 +15,7 @@ class Render(object): PRIORITY = {"^": 4,"*" : 3, "/": 3, ":": 3, "+": 2, "-":2, "(": 1} - def __init__(self, op_infix = {}, op_postfix = {}, other = {}, join = " ", type_render = {int: str, Fraction: str, FormalExp: str}): + def __init__(self, op_infix = {}, op_postfix = {}, other = {}, join = " ", type_render = {int: str, Fraction: str, str: str}): """Initiate the render @param op_infix: the dictionnary of infix operator with how they have to be render