Can I just partially override __setattr__?
<p>I'm imitating the behavior of the <code>ConfigParser</code> module to write a highly specialized parser that exploits some well-defined structure in the configuration files for a particular application I work with.  The files follow the standard INI structure:</p>

<pre><code>[SectionA]
key1=value1
key2=value2

[SectionB]
key3=value3
key4=value4
</code></pre>

<p>For my application, the sections are largely irrelevant; there is no overlap between keys from different sections and all the users only remember the key names, never which section they're supposed to go in.  As such, I'd like to override <code>__getattr__</code> and <code>__setattr__</code> in the <code>MyParser</code> class I'm creating to allow shortcuts like this:</p>

<pre><code>config = MyParser('myfile.cfg')
config.key2 = 'foo'
</code></pre>

<p>The <code>__setattr__</code> method would first try to find a section called <code>key2</code> and set that to 'foo' if it exists.  Assuming there's no such section, it would look inside each section for a key called <code>key2</code>.  If the key exists, then it gets set to the new value.  If it doesn't exist, the parser would finally raise an <code>AttributeError</code>.</p>

<p>I've built a test implementation of this, but the problem is that I also want a couple straight-up attributes exempt from this behavior.  I want <code>config.filename</code> to be a simple string containing the name of the original file and <code>config.content</code> to be the dictionary that holds the dictionaries for each section.</p>

<p>Is there a clean way to set up the <code>filename</code> and <code>content</code> attributes in the constructor such that they will avoid being overlooked by my custom getters and setters?  Will python look for attributes in the object's <code>__dict__</code> before calling the custom <code>__setattr__</code>?</p>
