擅长:python、mysql、java
<p>请参阅Python文档的以下部分:<a href="http://docs.python.org/2/reference/datamodel.html#special-method-lookup-for-new-style-classes" rel="nofollow">Special method lookups for new-style classes</a></p>
<blockquote>
<p>For new-style classes, implicit invocations of special methods are <strong>only guaranteed to work correctly if defined on an object’s type</strong>, not in the object’s instance dictionary.</p>
</blockquote>
<p>请按照链接详细说明这背后的基本原理。我所理解的基本思想是,应用于实例对象和类型对象(如<code>__repr__</code>)的特殊方法需要一致地调用,而不是有时需要显式参数,有时接收隐式参数。通过总是对对象类型调用方法,我们知道总是传递显式参数,但副作用是绕过了实例字典。在</p>