python确定某一类型的继承顺序__mro__
程序员文章站
2022-06-04 08:08:24
...
使用**__mro__**可以确定某一类型的继承顺序
注:只有数据类型包含__mro__属性,某一具体对象无法使用
【sample】
In [1]: import numpy as np
In [2]: dat = np.array([1])
In [3]: type(dat)
Out[3]: numpy.ndarray
In [4]: type(dat).__mro__ In [5]: np.ndarray.__mrp__
Out[4]: (numpy.ndarray, object) Out[5]: (numpy.ndarray, object)
In [6]: dat.__mro__
AttributeError: 'numpy.ndarray' object has no attribute '__mro__'