from dataclasses import dataclass @dataclass class UserInfo: first_name: str last_name: str age: int job: str | None hobbies: list[str] | None @property def full_name(self): return f'{self.first_name} {self.last_name}' @property def email(self): return f'{self.first_name[0]}{self.last_name}@matrix.com'
from dataclasses import dataclass, field- from dataclasses import dataclass
- @dataclass
- class UserInfo:
- first_name: str
- last_name: str
- age: int
job: strhobbies: list- job: str | None
- hobbies: list[str] | None
- @property
- def full_name(self):
- return f'{self.first_name} {self.last_name}'
- @property
- def email(self):
- return f'{self.first_name[0]}{self.last_name}@matrix.com'