From a543602d26bbc4f7675ed3576ff692e3255ec3cc Mon Sep 17 00:00:00 2001 From: Lafrite Date: Fri, 17 Apr 2015 16:38:16 +0200 Subject: [PATCH] remove space in new_s==old_s if they are sting for explicable --- pymath/explicable.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pymath/explicable.py b/pymath/explicable.py index 1db3b83..d764132 100644 --- a/pymath/explicable.py +++ b/pymath/explicable.py @@ -87,7 +87,7 @@ class Explicable(Renderable): new_s = self.STR_RENDER(s.postfix_tokens) else: new_s = self.STR_RENDER(s) - if new_s != old_s: + if not self.is_same_step(new_s, old_s): old_s = new_s yield new_s except AttributeError: @@ -96,8 +96,23 @@ class Explicable(Renderable): if noself: # Lui même new_s = self.STR_RENDER(self.postfix_tokens) - if new_s != old_s: + if not self.is_same_step(new_s, old_s): yield new_s + + def is_same_step(self, new, old): + """Return whether the new step is the same than old step + """ + try: + if new.replace(" ", "") == old.replace(" ", ""): + return True + else: + return False + except AttributeError: + if new == old: + return True + else: + return False +