I have a scenario where I've two dataclass which share some command keys. Let's say
@dataclass
class A
key1: str = ""
key2: dict = {}
key3: Any = ""
and class B
@dataclass
class B
key1: str = ""
key3: Any = ""
key4: List = []
Both of this class share some key value. Now I want to assign those common key value from class A to to class B instance.
One way I know is to convert both the class to dict
object do the process and convert it back to dataclass object. But from what I know sole purpose of dataclass is to effectively store data and manage. I believe there is some better approach.
Expected Input and Output
# State of dataclass A while B is not initialized
A(key1: "key1value", Key2: {"a": "a"}, key3: [1,2])
# State of B should be
B(key1: "key1value",key3: [1,2], key4: [])