3 ms·
There's all kinds of use cases for classes without dataclass. For example, just the other day I wrote a leaky bucket rate limiter class. It uses the __aenter__
by seanhunter 4y ago
There's all kinds of use cases for classes without dataclass. For example, just the other day I wrote a leaky bucket rate limiter class. It uses the __aenter__ and __aexit__ methods to do things in async with blocks.
I love dataclasses, but there needs to be a compelling reason to break everyone's code and the reason can't just be "I don't want one import and one decorator".
- glyph 4y agowhy do you think you can't define `__aenter__` and `__aexit__` on a dataclass?
- seanhunter 4y agoI don't. But it's really not a dataclass - it doesn't need slots etc.