Last active
December 21, 2015 02:59
-
-
Save taiki45/6239436 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
In [1]: class ListA(object): | |
...: def __init__(self, x, y): | |
...: self.x = x | |
...: self.y = y | |
...: def sum(self): | |
...: return self.x + self.y | |
...: | |
In [2]: a = ListA(4, 5) | |
In [3]: a | |
Out[3]: <__main__.ListA at 0x101cd0310> | |
In [4]: a.sum | |
Out[4]: <bound method ListA.sum of <__main__.ListA object at 0x101cd0310>> | |
In [5]: a.sum() | |
Out[5]: 9 | |
In [6]: b = ListA(3,4) | |
In [7]: b.sum() | |
Out[7]: 7 | |
In [8]: map(ListA.sum, [a, b]) | |
Out[8]: [9, 7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment