2 ms·
> Probably a controversial opinion, but I would like `self` removed, and have the class body be an init function. That would be weird in classes that override
by dragonwriter 4y ago
> Probably a controversial opinion, but I would like `self` removed, and have the class body be an init function.
That would be weird in classes that override the constructor (__new__), which is what is actually called (not __init__, except contingent on the result of the constructor) when the class is used as a callable.
Not to mention the need to define methods in the class body, and be able to distinguish them from local functions in the constructor/initializer, which is a pretty good argument against the class body being the constructor or initializer.
- saiojd 4y agoI agree that in the general case it does not work, but if we were to introduce an alternate dataclass/class definition syntax, I feel like something lightweight like this would be nice. (Local functions could just be prefixed with underscores, no need to distinguish them from private methods.)