propety

作者: EmptyBottl_520d | 来源:发表于2017-11-07 10:30 被阅读0次
class box(object):
    def __init__(self):
        self.width=0
        self.height=0
    def getsize(self):
        print "this is getsize(function)"
        return self.width,self.height
    def setsize(self,size):
        self.width,self.height=size
    def delsize(self):
        print "del ge dan"
        del self.width
        del self.height

    def __delattr__(self,name):
        print "nothing"
        super(box,self).__delattr__(name)
    def __getattr__(self,name):
        print "__getattr__----",name

    def __getattribute__(self,name):
        print "__getattribute__---",name
        return super(box,self).__getattribute__(name)
    size=property(getsize,setsize,doc="hello man",fdel=delsize)

    def smth():
        print "this is static method for box"

    smth=staticmethod(smth)

    def cmth(cls):
        print "this is class method for box",cls

    cmth=classmethod(cmth)

one=box()
one.size=100,50

======================= RESTART: /home/bottle/test.py =======================
>>> one.size
getattribute--- size
this is getsize(function)
getattribute--- width
getattribute--- height
(100, 50)

相关文章

  • propety

    ======================= RESTART: /home/bottle/test.py ===...

  • 动画

    transition动画语法 说明transition-propety 设置过渡的属性transition-d...

  • 九年助学路,宋河教育基金会终炼成“超级IP”!

    什么是超级IP? IP即Intellectual Propety,意即知识产权。超级IP是由系统方法论构建的,稀缺...

  • 属性

    关键字 H1 #@propety中的关键字有哪些 H2 补充: 修饰成员变量的__strong, __weak的作...

  • 12、python元类编程

    1.1.propety动态属性 在面向对象编程中,我们一般把名词性的东西映射成属性,动词性的东西映射成方法。在py...

网友评论

      本文标题:propety

      本文链接:https://www.haomeiwen.com/subject/vamdmxtx.html