On 5/4/2022 1:19 PM, Paul Moore wrote:
Maybe. But really what I want is a way to say "this is what type the attribute is, but don't assume the init argument is the same type". Or just not bother with all this at all. This is where it starts to just become not worth trying to make dataclasses do what I want, I might as well do it myself via init=False.
Not that it matters much, but you don't need to use init=False, just implement your own __init__:
>>> @dataclass ... class C: ... x: int ... y: int ... def __init__(self, x): ... self.x = x ... self.y = x * 2 ... >>> C(3) C(x=3, y=6) Eric _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UKOVPQN3MXQ6O2XEZKTEWTXBXIGSUONH/ Code of Conduct: http://python.org/psf/codeofconduct/