Why does .mro () in the metaclass have a different signature? The `mro 'handle of the' type 'object needs an argument`

In most types / classes in Python, I can call .mro()without arguments. But not on typehis descendants:

In [32]: type(4).mro()
Out[32]: [int, object]

In [33]: type(type(4)).mro()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-48a6f7fcd2fe> in <module>()
----> 1 type(type(4)).mro()

TypeError: descriptor 'mro' of 'type' object needs an argument

It seems I can get what I want with help type(type(4)).mro(type(4)), but why can't I directly call mro()in the same way as in other places?

+4
source share
1 answer

mro - - - C m, C.m(inst) inst.m(), C.m(), self.

mro type, type.mro(type).

+4

Source: https://habr.com/ru/post/1620774/


All Articles