from collections import *
class C(object):
def __iter__(self): pass
def __contains__(self, i): pass
def __len__(self): pass
def __getitem__(self, i): pass
issubclass(C, Mapping) => False
[issubclass(C, cls) for cls in Mapping.__mro__] => [False, True, True, True, True]
即C 确实实现了Sized、Iterable 和Container。
我本来希望,就像issubclass(C, Sized)
检查__len__
方法的存在一样,issubclass(C, Mapping)
会检查每个直接超类所需的三个方法的存在吗?