Dynamically add instance variables via decorator to a class in Python
<p>I want to instrument a class via a decorator, to add some <strong>instance</strong> variables that are specified by the author of the class.</p>

<p>I started with the following code, but this just adds <strong>class</strong> variables and I want <strong>instance</strong> variables (those that are normally 'declared' in __ init __)</p>

<p>What is a pythonic way to do this, while allowing the class author control over what they put in __ init __?</p>

<pre><code>def add_list_attributes(klass):
    for attribute in klass.list_attributes:
        setattr(klass, attribute, [])

    return klass

@add_list_attributes
class Person(object):

    list_attributes = [
        'phone_numbers'
    ]

    def __init__(self):
        pass

p1 = Person()
p1.phone_numbers.append('01234')

print p1.phone_numbers
</code></pre>
