在Python 2.5中,以下代码引发TypeError
:
>>> class X:
def a(self):
print "a"
>>> class Y(X):
def a(self):
super(Y,self).a()
print "b"
>>> c = Y()
>>> c.a()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in a
TypeError: super() argument 1 must be type, not classobj
如果我更换class X
用class X(object)
,它会奏效。这有什么解释?
3
您的“但是我用类X(object)替换了类X”解决了我的问题!thanx
—
AliBZ