__getattr__ on a class and not (or as well as) an instance
<p>I know I can write code like:</p>

<pre><code>class A :
    def __getattr__ (self, name) :
        return name
</code></pre>

<p>to trap access to undefined attributes on an instance of a class, so:</p>

<pre><code>A().ATTR == 'ATTR'
</code></pre>

<p>is <em>True</em>. But is there any way to do this for the class itself? What I'd like to be able to is to have the following two lines both work, and be distinguishable (ie., there are different magic methods called, or the magic method can tell how it was called)</p>

<pre><code>a = A().ATTR
b = A.ATTR
</code></pre>

<p>I suspect the answer is <strong>no</strong> but maybe there is some deep python ju-ju?</p>

<p><strong>Edit</strong>: The actual problem is extending a custom active record library in a backwards-compatible way. The ORM code supports code along the lines of </p>

<pre><code>ar = AR_people()
ar.find()
name = ar.name
</code></pre>

<p>to access tables, where <code>name</code> may get mapped to a column name which is different, e.g. <code>pe_name</code>. We want to be able to write something like</p>

<pre><code>ar.filter(AR_people.age &gt;= 21)
</code></pre>

<p>and end up with</p>

<pre><code>pe_age &gt;= 21
</code></pre>

<p>(much like other ORM libraries do), so <code>AR_people.age</code> needs to return an instance of a class that implements <code>__ge__</code> and so forth to do the conversion magic.</p>
