- class CBase:
- ‘‘
- counter = 0;
- __counter = 1;
-
-
-
- def __init__(self,name):
- self.name = name
- self.__private1 = 2
- print(‘__init__ base‘)
-
-
- def __del__(self):
- print(‘ base destruct‘)
-
-
-
-
-
- def Help(self):
- ‘‘
- print(‘---base help begin---/n‘,self.name)
- print(CBase.__counter)
-
- print(self.__private1)
- print(‘---base help end---/n‘)
-
- def Test(self):
- print(‘Base Test‘)
-
-
- class CHigh(CBase):
- def __init__(self):
- CBase.__init__(self,‘high‘)
- print(‘__init__ high‘)
-
- def __del__(self):
-
-
- print(‘ High destruct‘)
-
-
- def Test(self):
- print(‘High Test ‘)
-
-
-
-
-
- def Test(self,name):
- print(‘High Test have arg:‘,name)
-
- rh = CHigh()
- rh.Help()
- rh.Test();
- print(CBase.counter)
- print(rh.name)
Python 笔记 : 类和继承
原文:http://www.cnblogs.com/rrxc/p/4039422.html