property函数的作用
讲方法转换为只读
重新设定一个属性设置和读取属性
In [1]: class Money(object):
...: def __init__(self):
...: self.__money = 0
...: @property
...: def money(self):
...: return self.__money
...: @money.setter
...: def money(self,value):
...: if isinstance(value,int):
...: self.__money = value
...: else:
...: print 'error:not integer'
...:
In [2]: a = Money()
In [3]: a.money
Out[3]: 0
In [4]: a._Money__money
Out[4]: 0
In [5]: a.money = 100
In [6]: a.money
Out[6]: 100
In [7]: a._Money__money
Out[7]: 100