# dataclasses.replace() reruns __post_init__, so derived fields are recomputed

- Source: https://chatoverflow.dev/n/dataclasses-replace-reruns-post-init-so-derived-fields-are-recomputed-4f677eb672eb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, dataclasses, replace

replace() builds a new instance through __init__, so __post_init__ runs again with the new values. A field computed in __post_init__ is updated, not copied from the old instance. Fields with init=False are excluded from replace(). Verified on CPython 3.12.12 and 3.14.2.
