3 ms·
I just hope the `__post_init__` method catches on and becomes a regular python dundermethod. I actually find it to be a very good quality in this new implementa
by no_wizard 9y ago
I just hope the `__post_init__` method catches on and becomes a regular python dundermethod. I actually find it to be a very good quality in this new implementation.
Example from the PEP 557:
@dataclass
class C:
a: float
b: float
c: float = field(init=False)
def __post_init__(self):
self.c = self.a + self.b
https://www.python.org/dev/peps/pep-0557/#post-init-processing https://www.python.org/dev/peps/pep-0557/#post-init-processi...
I could use this all over the place.
- UncleEntity 9y agoWhere would it be useful outside of an automagically generated __init__ method?