|
|
|
|
|
by tedmiston
2956 days ago
|
|
Data Classes are a cool feature, useful, and a superior alternative to namedtuple. But while this was brewing, attrs ate their lunch. Data Classes just don't go far enough compared to what attrs [1] has provided for a while now. If there's a compelling reason to switch, I haven't found it yet. Can I use Data Classes in a library supporting Python 2.7, 3.4-3.7? I don't think the answer is yes today. [1]: https://github.com/python-attrs/attrs |
|
Meanwhile, I was not a user of attrs before, rather I used collections.namedtuple and then typing.NamedTuple. So, data classes is a win for me and other people like me who weren't using attrs. And you can continue to use attrs without being bothered at all.
In Raymond Hettinger's talk [0] at PyCon 2018, he even says that more features from attrs will likely get added, such as data validation [1]. And that his talk was the one chance for the developer (Eric Smith) to get praise, because everyone is going to instantly second guess every decision he made.
[0] https://www.youtube.com/watch?v=T-TwcmT6Rcw
[1] see 42:36 on future directions