Python recursively __getattribute__
<p>I need to implement such behavior:</p>

<pre><code>obj.attr1.attr2.attr3 --&gt; obj.attr1__attr2__attr3
</code></pre>

<p>It looks like I have to override obj's class __getattribute__ and also use python descriptors somehow.</p>

<p><strong>UPDATE:</strong></p>

<p>I have a django project.</p>

<p>obj is django-haystack's SearchResult instance, it contains a lot of de-normalized data (<strong>user__name</strong>, <strong>user__address</strong>) from django model, and I need to access it as <strong>result.user.name</strong> for compability reasons.</p>

<p><strong>UPDATE for THC4k's answer:</strong></p>

<p>What if I have:</p>

<pre><code>class Target(object):
    attr1 = 1
    attr1__attr2__attr3 = 5

&gt;&gt;&gt; proxy.attr1
1
&gt;&gt;&gt; proxy.attr1.attr2.attr3
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
AttributeError: 'int' object has no attribute 'attr2'
</code></pre>

<p>Any help will be much appreciated.</p>
