On Thu, Oct 28, 2021 at 11:08 AM Avi Gross via Python-list <python-list@python.org> wrote: > > Dave, > > You make me wonder about unintended side effects. Are we allowing the ++ and > --- operations into Python through a side door? >
class IncrementableInteger(int): def __pos__(self): return HalfIncremented(self) def __neg__(self): return HalfDecremented(self) class HalfIncremented(IncrementableInteger): def __pos__(self): return IncrementableInteger(self + 1) class HalfDecremented(IncrementableInteger): def __neg__(self): return IncrementableInteger(self - 1) Up to you to make the actual mutation work but have fun making a nightmare for subsequent maintainers! ChrisA PS. Nobody's ever stopping you from def __add_(self, other): return self * other + 3 Just sayin'. -- https://mail.python.org/mailman/listinfo/python-list