2
關於abc的標準文檔以及我讀過的其他教程都使用了定義抽象基類而不從對象繼承的示例。如果python抽象基類繼承自對象
class Foo(object):
def __getitem__(self, index):
...
def __len__(self):
...
def get_iterator(self):
return iter(self)
class MyIterable:
__metaclass__ = ABCMeta
@abstractmethod
def __iter__(self):
while False:
yield None
在過去,我總是讓我的類繼承對象有新風格的類。我應該和ABC一樣嗎?