m0_57901298 2021-09-04 22:18 采纳率: 58.3%
浏览 49
已结题

TypeError: __getattribute__() missing 1 required positional argument: 'value'

w = c.WriteOnly()
w.l #classes.OprationError

但是

Traceback (most recent call last):
  File "<pyshell#46>", line 1, in <module>
    w.l
TypeError: __getattribute__() missing 1 required positional argument: 'value'

附WriteOnly源码(测试)

class WriteOnly(object):
    def __getattr__(self, name):
        raise OprationError('Cannot get attribute')
    
    def __getattribute__(self, name):
        raise OprationError('Cannot get attribute')
  • 写回答

1条回答 默认 最新

  • Pliosauroidea 2021-09-04 23:35
    关注
    class WriteOnly(object):
        def __getattr__(self, name):
            raise SystemError('Cannot get attribute')
    
        def __getattribute__(self, name):
            raise SystemError('Cannot get attribute')
    
    
    w = WriteOnly()
    w.l
    

    img


    稍微改了一下,跑出来是这个效果

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 9月26日
  • 已采纳回答 9月18日
  • 创建了问题 9月4日