Maximum recursion depth error with getattr

前端 未结 1 998
醉话见心
醉话见心 2021-01-24 14:34

I have this code;

class NumberDescriptor(object):
    def __get__(self, instance, owner):
        name = (hasattr(self, \"name\") and self.name)
        if not n         


        
相关标签:
1条回答
  • 2021-01-24 14:53

    The getattr() call is calling your __get__.

    One way to work around this is to explicitly call through the superclass, object:

    object.__getattribute__(instance, name)
    

    Or, clearer:

    instance.__dict__[name]
    
    0 讨论(0)
提交回复
热议问题