4 ms·
Modern Python lacks coherent design: How do you define enums? with a superclass. How do you define data classes? With a class decorator. And then there's met
by kzrdude 7y ago
Modern Python lacks coherent design:
How do you define enums? with a superclass.
How do you define data classes? With a class decorator.
And then there's metaclasses too.
- joshuamorton 7y agoEnums are technically defined with a metaclass, as are abstract base classes and most other weird special classes (but in all cases you access the metaclass by subclassing something). Dataclasses are the one exception, and they do this for pragmatic reasons: multiple metaclasses are tricky. So a decorator allows the existence of an abstract dataclass, for example.