Parcourir la source

Eliminated repetitive replacement calls.

Sander Mathijs van Veen il y a 14 ans
Parent
commit
e567923a8c
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      line.py

+ 4 - 4
line.py

@@ -158,11 +158,11 @@ def generate_line(root):
             # Function call
             result = op + '(' + ', '.join(map(traverse, node)) + ')'
 
-        # An addition with negation can be written as a subtraction, e.g.:
-        # 1 + -2  ->  1 - 2
-        return result.replace('+ -', '- ')
+        return result
 
-    return traverse(root)
+    # An addition with negation can be written as a subtraction, e.g.:
+    # 1 + -2  ->  1 - 2
+    return traverse(root).replace('+ -', '- ')
 
 
 def is_negation(node):