__getattr__ 和__setattr__ 不是一对。
__getattribute__和setattr__ 是一对。
__getattr__只有在调用__getattribute__取不到值得时候才会被调用。
可以参见标准库的第三章具体说明。
<完>
本文深入探讨了Python中的__getattribute__和__getattr__方法的区别及用法,解释了它们在对象属性查找过程中的作用。
__getattr__ 和__setattr__ 不是一对。
__getattribute__和setattr__ 是一对。
__getattr__只有在调用__getattribute__取不到值得时候才会被调用。
可以参见标准库的第三章具体说明。
<完>
745
4715

被折叠的 条评论
为什么被折叠?