1. 首页
  2. 数据库
  3. 其它
  4. python的描述符(descriptor)、装饰器(property)造成的一个无限递归问题分享

python的描述符(descriptor)、装饰器(property)造成的一个无限递归问题分享

上传者: 2021-02-01 12:05:53上传 PDF文件 41.68KB 热度 8次
分享一下刚遇到的一个小问题,我有一段类似于这样的python代码: 复制代码 代码如下: # coding: utf-8 class A(object): @property def _value(self): # raise AttributeError(“test”) return {“v”: “This is a test.”} def __getattr__(self, key): print “__getattr__:”, key return self._value[key] if __name_
下载地址
用户评论