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?
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.
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.
Thanks!
EDIT: I found what I was looking for shortly after posting this!
Python dictionary from an object's fields
That's pretty much all I needed to know.