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 Container: | |
def __iter__(self): | |
return Iterator() | |
class Iterator: | |
def __iter__(self): | |
return self |
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 Container: | |
def __init__(self, list_): | |
self._list = list_ | |
def __len__(self): | |
return len(self._list) | |
def __getitem__(self, index): |
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 Line(object): | |
def __init__(self, a, b): | |
self.a = a | |
self.b = b | |
def __eq__(self, other): | |
return all(( | |
self.a == other.a, | |
self.b == other.b | |
)) |
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 ClassMethod(object): | |
"Emulate PyClassMethod_Type() in Objects/funcobject.c" | |
def __init__(self, f): | |
self.f = f | |
def __get__(self, obj, klass=None): | |
if klass is None: | |
klass = type(obj) | |
def newfunc(*args): |
NewerOlder