Код: Выделить всё
from dataclasses import astuple, dataclass
@dataclass
class Child:
name: str
@dataclass
class Parent:
child: Child
# this is what I want
p = Parent(Child("Tim"))
print(p)
# this is what I get
t = astuple(p)
print(Parent(*t))
Код: Выделить всё
Parent(child=Child(name='Tim'))
Parent(child=('Tim',))
Подробнее здесь: https://stackoverflow.com/questions/787 ... ss-astuple