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

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


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

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题