# Alternative to changing the __add__ of Integers class (need $0_{\mathbb Z} + x = x$, $x$ belonging to custom class)

I have a class called phi defined on certain ring $R$, which morally should be $\mathbb Z$-valued, $\phi: R \to \mathbb Z$. From that I need only that adding $0_{\mathbb Z}$ to the phi-elements does nothing, and the next (pseudocode) works for adding $0$ by the right to the phi elements:

```
class phi: ...
...
def __add__(self, other):
if other == 0:
return self
```

How can I define the addition to be trivial if the left argument is $0_\mathbb Z$ and the right in the phi class without changing the __add__ of the Integer class? (Or a workaround. Actually my target is not the integers but the sage symbolic ring, SR.)

You might want to have a look at the following entries in sagemath documentation

Thanks, I'm taking a look.