python extends

2789 ワード

"""
1.python        
                           
                                  
            
                  
2.            
                          
3.__init__       super                 

"""


class A1(object):
    TIME = "23 36 "

    def print(self):
        print("hello {} I am A1".format(self.who))

    def __init__(self, who):
        self.who = who
        print("A1 initmethod---------")


class A2(object):
    DATE = "20171017"

    def print(self):
        print("hello {} I am A2".format(self.who))

    def __init__(self, who):
        self.who = who
        print("A2 initmethod---------")


class A3(A2, A1):
    def __init__(self, why, who):
        print("A3 init--")
        self.why = why
        super(A3, self).__init__(who)

    def say(self):
        print(self.who)
        print(super(A3, self).print())

    @classmethod
    def xxoo(cls):
        print(cls.DATE)
        print(cls.TIME)


oo = A3("    ", "Mark")
oo.say()
oo.xxoo()