Re:Why Is the Migration to Python 3 Taking So Long?
by dfinninger on Thursday November 14, 2019 @02:07PM
(#21538319)
To your last point, check out Dataclasses[1].
@dataclass
class Foo:
arg1: str
arg2: int
arg3: int = 5 # default value
I use them a lot in my 3.7+ projects. It helps reduce the boilerplate for typical classes. (Where for me, typical classes are a 1:1 mapping of inputs to attributes)
And if you need to compute some values at object initialization, then they have a __post_init__() hook you can use [2].
And if you need to compute some values at object initialization, then they have a __post_init__() hook you can use [2].
[1] https://docs.python.org/3/library/dataclasses.html [2] https://docs.python.org/3/library/dataclasses.html#post-init...