Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 python 中,如果我写 class SomeClass(Frame): ,这是否意味着 SomeClass 实际上变成了一个 Frame,或者它只是继承自 Frame?我在任何地方都找不到直接的答案,我找到的每个答案都非常模糊。
我认为您很困惑-如果某物是子类的实例,那么它也具有超类的所有成员并且可以代替它们使用。在一个非常真实的意义上,一个实例SomeClass既是一个实例,SomeClass也是一个实例Frame。
SomeClass
Frame
>>> class Bar(Foo): pass ... >>> bar = Bar() >>> isinstance(bar, Foo) True