[issue35527] Make fields selectively immutable in dataclasses

2019-01-01 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi @rhettinger, this is similar to #33474. I started working on an implementation of this. With the implementation you propose, if a field has both init=True and frozen=True, it may be set after the creation of the instance: @dataclass class Pe

[issue35527] Make fields selectively immutable in dataclasses

2018-12-18 Thread Yury Selivanov
Yury Selivanov added the comment: +1. I've tried to use `field(frozen=True)` today and was surprised it's not supported. -- nosy: +yselivanov ___ Python tracker ___

[issue35527] Make fields selectively immutable in dataclasses

2018-12-18 Thread Raymond Hettinger
New submission from Raymond Hettinger : The unsafe_hash option is unsafe only because it doesn't afford mutability protections. This can be mitigated with selective immutability. @dataclass class Person: ssn: int = field(immutable=True) birth_city: int = field(immutable=True) name