python類初探

直接上例子:

import os
import string


class C(object):
   def __init__(self):
       print "c class"


class B(object):
    def __init__(self):
        print "this is super class"
    
    def test(self):
        print "test"


class A(C, B):
    __a = '444'
    def __init__(self, name):
'''
B.__init__(self)
'''
super(A, self).__init__()
        print 'hahaha'
        self.names = name


    def printout(self):
        super(A, self).test()
        print self.names
    
    def __del__(self):
        pass


if __name__ == '__main__':
   aobj = A('5566')
   aobj.printout()
   aobj.test()


運行結果:


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