|
|
|
|
|
by pansa2
1969 days ago
|
|
> Python is adding so many features that it's becoming something "not python" Here's an example I came across recently. It's from the official documentation for the `heapq` module, so I assume it's now considered the idiomatic way to write a wrapper for each item in a priority queue: @dataclass(order=True)
class PrioritizedItem:
priority: int
item: Any=field(compare=False)
That's completely different to the way such a class would have been written even in Python 3.4. It would have been a simple class with an explicit `__init__` and `__lt__`. Instead, the above dataclass sits on top of a mountain of complexity and everything about it is implicit.It's in violation of both "Simple is better than complex" and "Explicit is better than implicit". |
|