Let's say there is some class:
class Test():
pass
(1)Somewhere on SO and in documentation i read next:
mro()called at class instantiation, and its result is stored in__mro__.
Okay, that is still clear to me, cause in __mro__ something is really stored:
Test.__mro__
Out[48]: (__main__.Test, object)
Again, somewhere i read this:
To look up an attribute name Python searches:
a)Search the__dict__of all metaclasses on the__mro__found at C’s__class__.
b)If a data descriptor was found in step a, call its__get__()and exit.
c)Else, call a descriptor or return a value in the__dict__of a class on C’s own__mro__.
d)Call a non-data descriptor found in step a.
e)Else, return Metaclass-tree values
I can find out that there is no __mro__ in Test.__dict__:
'__mro__' in Test.__dict__
Out[49]: False
So accordingly to e clause from previous quote i guess that
__mro__ should be taken from "Metaclass-tree values" and hence from type.__dict__
Really, there is __mro__ in type.__dict__:
["mro:<method 'mro' of 'type' objects>",
"__mro__:<member '__mro__' of 'type' objects>"]
So what was mentioned above in (1) about
mro()result stored in__mro__attribute from documentation doesn't really works this way?How does
<member '__mro__' of 'type' objects>results to(__main__.Test, object)?
Maybe you could show some source code to understand what really happens when i call Test.__mro__..