A Python "catch all" method for undefined/unimplemented attributes in classes
<p>I <em>love</em> Python's <code>@property</code> decorate system.  I love that you can run custom code when you call <code>aClassObect.attribute</code>.  Especially for validating data when you're setting an attribute.  However, one thing that I want, but I can't find, is a way to run custom code when trying to set an attribute that doesn't exist.  For example, say I've got the following class:</p>

<pre><code>class C(object):
    def __init__(self):
        self._x = None

    @property
    def x(self):
        """I'm the 'x' property."""
        return self._x

    @x.setter
    def x(self, value):
        self._x = value

    @x.deleter
    def x(self):
        del self._x
</code></pre>

<p>Now, if I have <code>myObj</code>, which is an instance of class <code>C</code>, and I call <code>myObject.x = 42</code>, it will run the appropriate setter, which is great for validating data.  But this doesn't stop someone from calling <code>myOjbect.b = 47</code>, and it will happily create a new attribute called <code>b</code>.  Is there some way to run special code when setting a new attribute?  I'd the ability to raise errors to say something like "error, this attribute doesn't exist".</p>
