python property

@property

@num.setter

class Test(object):
    def __init__(self):
       self.__num = 100

    @property
    def num(self):
        print("----getter----")
        return self.__num

    @num.setter
    def num(self, newNum):
        print("----setter----")
        self.__num = newNum

  

posted @ 2017-07-10 21:28  AlamZ  阅读(147)  评论(0编辑  收藏  举报