Restore Python class to original state
<p>I have a class where I add some attributes dynamically and at some point I want to restore the class to it's pristine condition without the added attributes.</p>

<p>The sistuation:</p>

<pre><code>class Foo(object):
  pass

Foo.x = 1
# &lt;insert python magic here&gt;
o = Foo() # o should not have any of the previously added attributes
print o.x # Should raise exception
</code></pre>

<p>My initial thought was to create a copy of the original class:</p>

<pre><code>class _Foo(object):
  pass

Foo = _Foo
Foo.x = 1
Foo = _Foo # Clear added attributes
o = Foo()
print o.x # Should raise exception
</code></pre>

<p>But since Foo is just a reference to _Foo any attributes get added to the original _Foo as well. I also tried</p>

<pre><code>Foo = copy.deepcopy(_Foo)
</code></pre>

<p>in case that would help but apparently it does not.</p>

<p><strong>clarification</strong>:</p>

<p>The user should not need to care about how the class is implemented. It should, therefore, have the same features of a "normally defined" class, i.e. introspection, built-in help, subclassing, etc. This pretty much rules out anything based on <code>__getattr__</code></p>
