class NegatableString(str):
def __rsub__(self, other):
if other.endswith(self):
return other[:len(other)-len(self)]
else:
raise ValueError("Cannot subtract {!r} from {!r}".format(self, other))
x = NegatableString("abc")
"123abc" - x
'123'
"123def" - x