我有一个对象定义如下
class a():
@property
def prop(self):
print("hello from object.prop")
@property
def prop1(self):
print("Hello from object.prop.prop")
当我打电话
>>> obj = a()
>>> obj.prop
hello from object.prop
>>> obj.prop.prop
我收到以下回溯错误
Traceback (most recent call last):
File "object_property.py", line 13, in <module>
a.prop.prop1
AttributeError: 'NoneType' object has no attribute 'prop1'
我想弄清楚是否可以为对象定义嵌套属性?