Why __dict__can't encoder material be used to access an attribute? For example, in my instance, Plone dir(portal)includes index_htmlbut portal.index_htmlthrows an AttributeError. This is also true for the attribute __class__ Products.ZCatalog.Catalog.mybrains. Is there a good reason why dir()you can’t be trusted?
Similar to a module inspect, I see that they use object.__dict__['x']instead of accessing attributes for this reason and because they do not want to run magic getattr.
source
share