auto generate Python Object Member
Does not use Python __slots__ as default
python dataclasses members
from dataclasses import dataclass from datetime import date # Slots option is available after python 3.10 @dataclass(slots=True) class User: id: int name: str birthdate: date admin: bool = False
Immutable
@dataclass(frozen=True)
Order
@dataclass(order=True)
Hash Key
@dataclass(unsafe_hash=True)
Default value for dynamic type is error
@dataclass(unsafe_hash=True) class User: id: int name: str birthdate: date admin: bool = False friends: List[int] = []
[파이썬] 데이터 클래스 사용법 (dataclasses 모듈)
Engineering Blog by Dale Seo
https://www.daleseo.com/python-dataclasses/
![[파이썬] 데이터 클래스 사용법 (dataclasses 모듈)](https://res.cloudinary.com/daleseo/image/upload/v1648323273/daleseo/og.png)

Seonglae Cho