Yielding a dictionary containing an object's attributes in Python
<p>I'm currently trying to write a piece of code that will dump all attributes of a given class instance to a dictionary so that I can change them without changing the source object. Is there a method for doing this, or perhaps a built-in dictionary I can copy and access?</p>

<p>What I'm really doing is making a special class that copies the actual attributes (and their corresponding values) from instances of varying other classes. Basically it would mimic any instance of any class.</p>

<p>For example, object x has attributes x.name and x.number, "Joe" and 7, respectively. I want my new object mimic, object y, to copy the attributes so that y now has attributes y.name and y.number, "Joe" and 7.</p>

<p>Thanks!</p>

<p><strong>EDIT:</strong> <em>I found what I was looking for shortly after posting this!</em></p>

<p><a href="http://stackoverflow.com/questions/61517/python-dictionary-from-an-objects-fields">Python dictionary from an object&#39;s fields</a></p>

<p>That's pretty much all I needed to know.</p>
