I have two dataclasses inside bookmodel, one inherited from the other:
@dataclass(frozen=True)
class BookOrder:
category: str
name: str
color: str
price: int
volume: int
@dataclass(frozen=True)
class ClientOrder(BookOrder):
client_id: str
Then in another .py file, I need to init a ClientOrder instance using BookOrder:
from book_model import BookOrder
# ...
@dataclass
class Client:
id: str
def place_book_order(self, book_order: BookOrder):
# want to init a ClientOrder HERE!!!
Since BookOrder is NOT callable, I cannot pass self.id to it. I was wondering if there's an elegant way to achieve this?
Update
Guess what I am trying to ask is, is there any other way to initialize a ClientOrder using BookOrder other than the below method?
client_order=ClientOrder(book_order.categry, book_order.name, ..., self.client_id)