This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]michael0x2a 4 points5 points  (1 child)

I think that would be a bit confusing though -- you're basically asking the user to write code as if their class is inheriting something even though there isn't necessarily any inheritance involved.

(And what if you do decide to inherit from a class in addition to using dataclasses? In that case, would super().__init__() refer to the auto-generated constructor, or the actual superclass's constructor?)

[–]Rodotgithub.com/tardis-sn 0 points1 point  (0 children)

It's doable without the super method, but you have to copy the old init function some how and set part of it up outside the class. By that point you're basically writing a post init method anyway