Detecting when a new attribute is added to a object in Python?
<p>I would like to have a special obj that does the following:</p>

<pre><code>obj.newly_created_attribute = some_value
</code></pre>

<p>Obviously, all objects will allow this. But I would like the previous code to automatically call a method when newly_created_attribute is not yet a attribute of obj. In my particular case, I wish to set up a custom get and set method for obj.newly_created_attribute (a property now).</p>

<p>Is there any way to do this? Some way to specify a callback that will be run whenever a new attribute is added to a object?</p>
