From 9a141ec2f79f56f057d0c337e4cfef8acdb7d2db Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Fri, 11 Mar 2016 18:29:05 +0300 Subject: [PATCH] avoid a sideeffect in r_parenthesis --- pymath/calculus/operator/operator.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pymath/calculus/operator/operator.py b/pymath/calculus/operator/operator.py index b3e4e61..ae0a1ed 100644 --- a/pymath/calculus/operator/operator.py +++ b/pymath/calculus/operator/operator.py @@ -167,7 +167,6 @@ class Operator(): """ Add parenthesis for left operand if necessary """ ans = opl try: - # TODO: Je pige pas pourquoi quand on enlève .name ça marche plus... |lun. avril 27 19:07:24 CEST 2015 if opl.mainOp.name == "sub1": ans = opl elif opl.mainOp.priority < self.priority: @@ -183,17 +182,18 @@ class Operator(): def r_parenthesis(self, op, str_join=False): """ Add parenthesis for rigth operand if necessary """ + ans = op try: if op.mainOp.priority < self.priority: - op = flatten_list(["(", op, ")"]) + ans = flatten_list(["(", ans, ")"]) except AttributeError: # op has not the attribute priority try: - if int(op) < 0: - op = ['(', op, ')'] + if int(ans) < 0: + ans = ['(', ans, ')'] except ValueError: pass - ans = flatten_list([op]) + ans = flatten_list([ans]) if str_join: ans = ' '.join([str(i) for i in ans]) return ans