bit of an odd question here. If I have two separate objects, each with their own variables and functions, is there any way those two objects can be combined into one single object?
To be more specific: I have an object with 15 variables in it and then I have my self object. I want to load those variables into self. Is there any easy way to do this or do I have to do it manually?
Use the
__dict__property:self.__dict__.update(other.__dict__)There are corner cases where this won’t work, notably for any variables defined in the class, rather than in a method (or in other “running code”).
If you want to copy pretty much everything over: