python __getattr__ and __name__
<p>I'm using "new style" classes in Python 2.6 and am having trouble with __getattr__ in a subclass.</p>

<p>If the subclass implements like such...</p>

<pre><code>def __getattr__(self, name):
    if self.__folderDict.has_key(name):
        if name == 'created':
            return doSomethingSpecial(self.__folderDict[name])
        return self.__folderDict[name]
    else:
        raise AttributeError()
</code></pre>

<p>It's not clear to me why my attribute exception gets thrown for a reference to __name__ ?</p>

<p>My understand is that __getattr__ should not even get called and that __name__ should be fullfilled by __getattribute__ since I'm using new style?</p>

<p>Here's a more complete example...</p>

<pre><code>class Base(object):
    @staticmethod
    def printMsg(msg, var):
        print msg + str(var)
        return

    def printName(self):
        Base.printMsg('#', self.__name__)
        return

class Derived(Base):
    def __getattr__(self, name):
        if self.__testDict.has_key(name):
            return self.__testDict[name]
        else:
            raise AttributeError()

    __testDict = {'userid': 4098}


d = Derived()
print d.userid
d.printName()
</code></pre>

<p>The result is...</p>

<pre><code>4098
Traceback (most recent call last):
File "D:/.../Scratch/scratch01.py", line 24, in &lt;module&gt;
d.printName()
File "D:/.../Scratch/scratch01.py", line 17, in __getattr__
raise AttributeError()
AttributeError
</code></pre>
