今天我发现python对象没有__mro_entries__可以用作基类。
例子:
class Base:
def __init__(self, *args):
self.args = args
def __repr__(self):
return f'{type(self).__name__}(*{self.args!r})'
class Delivered(Base):
pass
b = Base()
d = Delivered()
class Foo(b, d):
pass
print(type(Foo) is Delivered)
print(Foo)
Run Code Online (Sandbox Code Playgroud)
True
Delivered(*('Foo', (Base(*()), Delivered(*())), {'__module__': '__main__', '__qualname__': 'Foo'}))
Run Code Online (Sandbox Code Playgroud)
结果Foo将是类的实例Delivered,并且它不是有效的类型。
我确实理解以下用例,__mro_entries__但是使用对象而不__mro_entries__作为基类的用例是什么。这是Python的一个错误吗?