avoid a sideeffect in r_parenthesis
This commit is contained in:
parent
a0b014dd08
commit
9a141ec2f7
@ -167,7 +167,6 @@ class Operator():
|
|||||||
""" Add parenthesis for left operand if necessary """
|
""" Add parenthesis for left operand if necessary """
|
||||||
ans = opl
|
ans = opl
|
||||||
try:
|
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":
|
if opl.mainOp.name == "sub1":
|
||||||
ans = opl
|
ans = opl
|
||||||
elif opl.mainOp.priority < self.priority:
|
elif opl.mainOp.priority < self.priority:
|
||||||
@ -183,17 +182,18 @@ class Operator():
|
|||||||
|
|
||||||
def r_parenthesis(self, op, str_join=False):
|
def r_parenthesis(self, op, str_join=False):
|
||||||
""" Add parenthesis for rigth operand if necessary """
|
""" Add parenthesis for rigth operand if necessary """
|
||||||
|
ans = op
|
||||||
try:
|
try:
|
||||||
if op.mainOp.priority < self.priority:
|
if op.mainOp.priority < self.priority:
|
||||||
op = flatten_list(["(", op, ")"])
|
ans = flatten_list(["(", ans, ")"])
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# op has not the attribute priority
|
# op has not the attribute priority
|
||||||
try:
|
try:
|
||||||
if int(op) < 0:
|
if int(ans) < 0:
|
||||||
op = ['(', op, ')']
|
ans = ['(', ans, ')']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
ans = flatten_list([op])
|
ans = flatten_list([ans])
|
||||||
if str_join:
|
if str_join:
|
||||||
ans = ' '.join([str(i) for i in ans])
|
ans = ' '.join([str(i) for i in ans])
|
||||||
return ans
|
return ans
|
||||||
|
Loading…
Reference in New Issue
Block a user