MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / MultiplyNodeAlt

Class MultiplyNodeAlt

example_code/item_050.py:84–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class MultiplyNodeAlt(NodeAlt):
85 def __init__(self, left, right):
86 self.left = left
87 self.right = right
88
89 def evaluate(self):
90 left = self.left.evaluate()
91 right = self.right.evaluate()
92 return left + right
93
94 def pretty(self):
95 left_str = self.left.pretty()
96 right_str = self.right.pretty()
97 return f"({left_str} * {right_str})"
98
99
100print("Example 2")

Callers 1

item_050.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected