Python learning built-in attributes 2

1 Pit of built-in attributes:

    

class Person():
    def __getattribute__(self, item):
        print('执行属性拦截')
        if(item.startswith('a')):
            return 'hahaha'
        else:
            return self.test



    def test(self):
        print('heihei...')


p = Person()
p.a

p.b #A recursive call was generated...causing an error in the program.

    

Guess you like

Origin blog.csdn.net/Bruce_Zhang0828/article/details/80994662