Google了好几下, 找到了一个看起来比较靠谱的解释:
According to Webster, a property is a characteristic that belongs to a...属性值合法性验证
在上面的例子中, foo.name只有getter方法, 是只读的, 但其实property也是可修改的, 只需要为它添加一个setter方法就行了....一种解决方案是按照Java风格, 实现一个Java式的setter方法, 通过item.set_price(price)设置price属性, 然后在set_price方法里写验证代码....item.count = 2
print(item.price)
但下面的语句执行时便会报错了:
item = Item('Bread', 1, -10)
# or
item.price = -10
会报出同一个错误...通过class Foo访问Foo.name得到的是property对象, 而非property值.
2. 访问 foo.name时返回的是Foo.name的property值.