static and class method

the different between static method and class method

class A(object):

    @classmethod
    def func1(self, *args):
        print "This is func1 of A"

    @staticmethod
    def func2(*args):
        print "This is static func2 of A"

class B(A):

    @classmethod
    def func1(self, *args):
        print "This is func1 of B"

    @staticmethod
    def func2(*args):
        print "This is static func2 of B"


b = B()
b.__class__ = A
b.func2()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章