擅长:python、mysql、java
<blockquote>
<p>Problem is that this error is found at runtime!</p>
</blockquote>
<p>嗯,是Python。。。大多数错误都会在运行时出现。</p>
<p>据我所知,最常见的模式是在Python中,基本上就是您所描述的:让基类的<code>speak</code>方法抛出一个异常:</p>
<pre><code>class Animal():
def speak(self):
raise NotImplementedError('You need to define a speak method!')
</code></pre>