From 20c9c208366ab402106546f461c2c9c05549c44e Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sat, 28 Feb 2015 23:02:41 +0100 Subject: [PATCH] Enable to initialize Expression with Expression --- pymath/expression.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymath/expression.py b/pymath/expression.py index 1dc4fe0..2f63b3d 100644 --- a/pymath/expression.py +++ b/pymath/expression.py @@ -71,6 +71,8 @@ class Expression(Explicable): expression.postfix_tokens = str2tokens(exp) elif type(exp) == list: expression.postfix_tokens = flatten_list([tok.postfix_tokens if Expression.isExpression(tok) else tok for tok in exp]) + elif type(exp) == Expression: + return exp else: raise ValueError("Can't build Expression with {} object".format(type(exp))) @@ -95,7 +97,6 @@ class Expression(Explicable): methods_attr = {'simplify':simplify, '_isPolynom': is_polynom, 'postfix_tokens': [token]} fake_token = type('fake_str', (str,Explicable, ), methods_attr)(token) return fake_token - else: raise ValueError("Unknow type in Expression: {}".format(type(token)))