Created
January 3, 2016 05:47
-
-
Save dstoza/5cd5b1d7547fe6a076da 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 Num(): | |
... def __init__(self, value): | |
... self.value = value | |
... def get(self): | |
... return self.value | |
... def __add__(self, other): | |
... return Num(self.value + other.value) | |
... | |
>>> a = Num(3) | |
>>> b = a + Num(5) | |
>>> b.get() | |
8 | |
>>> b | |
<__main__.Num object at 0x7f503fa73908> | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment