Questions

学习过程中遇到的不理解的东西。

Python

1.__getattribute__()引起的错误,注释掉该方法无错。猜测:__getattribute__()导致xss()没有绑定到实例上。

class A():
    def __init__(self, a):
        self.a = a
    def xss(self):
        print("hello", self.a)
    def __getattribute__(self, item):
        print("在调用任何属性之前调用")

a = A(4)
a.xss()

提示错误:

a.xss()
TypeError: 'NoneType' object is not callable