擅长:python、mysql、java
<p><strong>不要</strong>为此使用<code>__getattribute__</code>:它并没有像您所想的那样做。(它是Python机器的一个特殊部分,主要用于实现新的属性访问魔术)</p>
<p>对于普通属性访问,请使用<code>getattr</code>/<code>setattr</code>/<code>delattr</code>内置函数:</p>
<pre><code>self.example == getattr(self, 'example')
super(B, self).example == getattr(super(B, self), 'example')
</code></pre>
<p>(如果您想了解<code>__getattribute__</code>的作用,请阅读<a href="http://docs.python.org/howto/descriptor.html" rel="noreferrer">Descriptor HowTo Guide</a>和Python <a href="http://docs.python.org/reference/datamodel.html" rel="noreferrer">Data model</a>引用。)</p>