4 ms·
What's the advantage of this over class decorators? @decorator class SomeClass: ... To me, class decorators seem to be much easier to reason ab
by Garlef 5y ago
What's the advantage of this over class decorators?
@decorator
class SomeClass:
...
To me, class decorators seem to be much easier to reason about.
- Garlef 5y agoAh... https://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators https://stackoverflow.com/questions/1779372/python-metaclass...
- abdusco 5y ago>>> import this > ... > Explicit is better than implicit. > ... > There should be one-- and preferably only one --obvious way to do it. It's one of Python's philosophies (/s). I agree that this is a more explicit way to handle metaprogramming in Python. It's analogous to method decorators, unlike metaclasses, which has no "metamethod" equivalent (AFAIK).