擅长:python、mysql、java
<p>回答你暗示的问题:</p>
<blockquote>
<p>In Java the static method would get inherited so I wouldn't even need
the super call, but in Python this does not seem to be the case.</p>
</blockquote>
<p><code>staticmethod</code>s<strong>是</strong>继承的:</p>
<pre><code>class A:
@staticmethod
def a():
print('Hello')
class B(A):
def b(self):
self.a()
b = B()
b.a()
b.b()
</code></pre>
<p>输出:</p>
^{pr2}$
<p>请注意,您不能简单地写下:</p>
<pre><code>class B(A):
def b(self):
a()
</code></pre>
<p>Python永远不会将一个简单的名称解析为一个方法/staticmethod;对于Python来说,<code>a()</code><em>必须</em>是一个本地或全局的函数调用。必须使用<code>self.a</code>引用实例,或者使用<code>B.a</code>引用类。在</p>
<p>在python中,<code>self</code>与当前的类引用一样是显式的。不要与Java的隐式<code>this</code>混淆。在</p>