How to handle call to __setattr__ from __init__?
<p>I have written a class that will be used to store parameters in a convenient way for pickling. It overloads <code>__setattr__</code> for convenient access. It also uses a list to remember the order in which attributes where added, so that the iteration order is predictable and constant. Here it is:</p>

<pre><code>class Parameters(object):
    def __init__(self):
        self._paramOrder = []

    def __setattr__(self, name, value):
        self._paramOrder.append(name)
        object.__setattr__(self, name, value)

    def __delattr__(self, name):
        self._paramOrder.remove(name)
        object.__delattr__(self, name)

    def __iter__(self):
        for name in self._paramOrder:
            yield self.name

    def iteritems(self):
        for name in self._paramOrder:
            yield name, self.name
</code></pre>

<p>The problem is that <code>__init__</code> calls my overloaded <code>__setattr__</code> in order to add the <code>_paramOrder</code> to the instance dictionary. Is there a way to handle this without adding a special case to <code>__setattr__</code>?</p>
