fake_str in expression

This commit is contained in:
Lafrite 2014-12-22 11:21:58 +01:00
parent 5b7c9d412c
commit 4c7ede0956
1 changed files with 10 additions and 1 deletions

View File

@ -67,7 +67,16 @@ class Expression(object):
simplified = lambda x:x simplified = lambda x:x
is_number = True is_number = True
methods_attr = {'simplify':simplify, 'simplified':simplified, 'isNumber': is_number} 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 return fake_token
else: else: