Super ()不适合与 staticmethod 一起使用吗?
当我尝试
class First(object):
@staticmethod
def getlist():
return ['first']
class Second(First):
@staticmethod
def getlist():
l = super(Second).getlist()
l.append('second')
return l
a = Second.getlist()
print a
我得到以下错误
Traceback (most recent call last):
File "asdf.py", line 13, in <module>
a = Second.getlist()
File "asdf.py", line 9, in getlist
l = super(Second).getlist()
AttributeError: 'super' object has no attribute 'getlist'
如果我将 staticmethod 更改为 classmethod,并将类实例传递给 super () ,那么就可以正常工作了。我是不是把 super (type)这个词叫错了,还是我漏掉了什么?