python 继承中的一个super使用

1 class C(P):
2     def __init__(self):
3         super(C,self).__init__()
4         print "calling C's constructor!"

在这个继承的例子中,不会因为调用了子类的__init__()方法,而自动调用父类的该方法,必须明确的调用,否则无效,和java差距很大。

super方法,比直接使用P.__init__()要灵活,经来代码改动较少

原文地址:https://www.cnblogs.com/harveyaot/p/2982586.html