Jun-01-2019, 02:15 PM
Is it possible (for educational purposes), to redefine the behavior of a method such as __add__ for the int class? I know that one can modify _add__ for a custom object but I want to know, for my edification only, whether I could, for example, change simple integer addition to be subtraction. That is, where typing 6+5 would result in 1 (rather than 11). Please don't ask why anyone would want to do this, it is merely to understand some of the underlying structure of Python. Thanks.