Files
pydantic/docs/examples/dataclasses_post_init_post_parse.py
T
2020-05-31 14:54:12 +01:00

23 lines
341 B
Python

from pydantic.dataclasses import dataclass
@dataclass
class Birth:
year: int
month: int
day: int
@dataclass
class User:
birth: Birth
def __post_init__(self):
print(self.birth)
def __post_init_post_parse__(self):
print(self.birth)
user = User(**{'birth': {'year': 1995, 'month': 3, 'day': 2}})