首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

The process of attribute lookup in python

如果objectname是实例: 1)Check objectname.__class__.__dict__ for attrname. If it exists and is a data-descriptor, return the descriptor result. Search all bases of objectname.__class__ for the same case. (在父类,以及父类的基类中查找data-descriptor属性,找到data-descriptor才返回) 2)Check objectname.__dict__ for attrname, and return if found. (在实例自身中 查找,只要找到就返回,不管是不是descriptor属性) 3)Check objectname.__class__.__dict__ for attrname. 似乎还要加上objectname.__class__.__basses__.__dict__ If it exists and is a non-data descriptor, return the descriptor result. If it exists, and is not a descriptor, just return it. (If it exists and is a data descriptor, we shouldn't be here because we would have returned at point 2.) (在父类中查找non-data descriptor和非descriptor属性,找到就返回)

02
领券