问题
Is there some introspection method allowing to reliably obtain the underlying data structure of an object instance, that is unaffected by any customizations?
In Python 3 an object's low-level implementation can be deeply obscured: Attribute lookup can be customized, and even the __dict__
and __slots__
attributes may not give a full picture, as they are writeable. dir()
is explicitly meant to show "interesting" attributes rather than actual attributes, and even the inspect
module doesn't seem to provide such functionality.
来源:https://stackoverflow.com/questions/42497929/lowlevel-introspection-in-python3