From 52ff23a74997261a12ae38f86b22258c5ec6cbe9 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Tue, 9 Feb 2016 10:14:54 +0300 Subject: [PATCH] transform if to try/except in develop_steps --- pymath/calculus/expression.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pymath/calculus/expression.py b/pymath/calculus/expression.py index 742e0e5..b4aa488 100644 --- a/pymath/calculus/expression.py +++ b/pymath/calculus/expression.py @@ -218,14 +218,14 @@ class Expression(Explicable): def develop_steps(self, tokenList): """ From a list of tokens, it develops steps of each tokens """ - # TODO: Attention les étapes sont dans le mauvais sens |lun. avril 20 10:06:03 CEST 2015 tmp_steps = [] - with Expression.tmp_render(): - for t in tokenList: - if hasattr(t, "explain"): + for t in tokenList: + try: + with Expression.tmp_render(): tmp_steps.append([i for i in t.explain()]) - else: - tmp_steps.append([t]) + except AttributeError: + tmp_steps.append([t]) + if max([len(i) for i in tmp_steps]) == 1: # Cas où rien n'a dû être expliqué. return []