python property

class telnetClient(object):
    def __init__(self,addr,port=23):
        self.addr=addr
    # @property    
    # def ip(self):
    #     return self.addr
    # @ip.setter   
    # def ip(self,ipaddr):
    #     self.addr=ipaddr   
    def getip(self):
        return self.addr
    def setip(self,value):
        self.addr=value
    property(getip,setip)         

t=telnetClient("127.0.0.1")
# t.ip="127.0.0.2"
# print(t.ip)    

 

posted @ 2018-03-16 10:58  howhy  阅读(147)  评论(0编辑  收藏  举报