From 4c7ede095663c854b1d1f18305cb402416accab1 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Mon, 22 Dec 2014 11:21:58 +0100 Subject: [PATCH] fake_str in expression --- pymath/expression.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pymath/expression.py b/pymath/expression.py index 0123fec..591d76b 100644 --- a/pymath/expression.py +++ b/pymath/expression.py @@ -67,7 +67,16 @@ class Expression(object): simplified = lambda x:x is_number = True methods_attr = {'simplify':simplify, 'simplified':simplified, 'isNumber': is_number} - fake_token = type('fake_obj', (int,), methods_attr)(token) + fake_token = type('fake_int', (int,), methods_attr)(token) + return fake_token + + elif type(token) == str: + # On crée un faux str en ajoutant la méthode simplify et simplified et la caractérisique isNumber + simplify = lambda x:[x] + simplified = lambda x:x + is_polynom = True + methods_attr = {'simplify':simplify, 'simplified':simplified, '_isPolynom': is_polynom} + fake_token = type('fake_str', (str,), methods_attr)(token) return fake_token else: