I am trying to acquire a basic understanding of python introspection and in doing so I found the in that regard useful mro()
method mentioned here.
When I (as an introspection exercise) tried to use said method and the builtin dir()
function in an attempt to find out where mro()
might live, I however was unable to succeed. Why?
Here is my approach:
the
mro()
method obviously is available without any imports (unlikeinspect.getmro()
which is part of theinspect
module; e.g.str.mro()
returns[<class 'str'>, <class 'object'>]
Since
str.mro()
returns[<class 'str'>, <class 'object'>]
, themro()
method should live somewhere instr
and/orobject
.Yet neither
dir(str)
nordir(object)
appear to contain the mro() method. Also help() and help(str.mro) do not enlighten the puzzled student of introspection.