4 ms·
FYI there is also @dataclass(frozen=True) this tends to be enough for my usecases. you can still circumvent (and sometimes have to in dataclass post_init)
by m_mueller 5y ago
FYI there is also
@dataclass(frozen=True)
this tends to be enough for my usecases. you can still circumvent (and sometimes have to in dataclass post_init) with object.__setattr__.
- diegojromero 5y agoI knew about dataclasses when I started writting gelidum, but I wanted to make the immutable objects be from any classes, those under my control or not. Having said that, I think dataclasses are a better solution for making immutable objects if the class is going to be made from the start.