python invoke super parent method

  1 #!/usr/bin/env python
  2 #encoding=utf-8
  3 class A(object):
  4   def __init__(self):
  5     print "a init"
  6     print self.__class__
  7
  8   def do(self):
  9     print self.__class__.__name__
 10 class B(A):
 11   def __init__(self):
 12     #A.__init__(self)
 13     super(B,self).__init__()
 14     print "b init"
 15
 16   def do(self):
 17     print "ok buddy"
 18     super(B,self).do()
 19
 20 b=B()
 21 b.do()

原文地址:https://www.cnblogs.com/lexus/p/2790988.html