Created
October 29, 2018 18:20
-
-
Save unutbu/2be784436f1495015b16b0c6eb5f21f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyInt(int): | |
def __add__(self, other): | |
print('__add__({}, {})'.format(self, other)) | |
return MyInt(other+self) | |
def __radd__(self, other): | |
print('__radd__({}, {})'.format(self, other)) | |
return MyInt(int(self)+other) | |
c = MyInt(5) | |
p = 1 | |
print(type(p+c)) | |
print('-'*80) | |
print(type(c+p)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment