MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / __add__

Method __add__

Solutions/2_4/mutint.py:24–30  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

22
23 # Implement the "+" operator. Forward operands (MutInt + other)
24 def __add__(self, other):
25 if isinstance(other, MutInt):
26 return MutInt(self.value + other.value)
27 elif isinstance(other, int):
28 return MutInt(self.value + other)
29 else:
30 return NotImplemented
31
32 # Support for reversed operands (other + MutInt)
33 __radd__ = __add__

Callers

nothing calls this directly

Calls 1

MutIntClass · 0.85

Tested by

no test coverage detected