Ad
Code
Diff
  • 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: str
    • hobbies: 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'