New submission from pavel-lexyr <pa...@lexyr.com>:
PEP 20 states: > There should be one-- and preferably only one --obvious way to do it. As of right now, two very similar constructions for making a lightweight dataclass exist in Python. collections.namedtuple is one of them. dataclasses.dataclass is the other*. The behaviour they provide is very similar. And with the functions .astuple() and the `frozen` constructor argument of the dataclass, one could consider it to be almost a direct superset of the namedtuple. Having two different classes with very similar behaviour is not considered a good practice. I propose merging the two classes' features into one and to deprecate the other, to prevent unnecessary ambiguity. * To get deeper into semantics, we might consider types.SimpleNamespace to be the third. This is out of this issue's scope - the reader is welcome to follow up in another one. ---------- components: Library (Lib) messages: 398421 nosy: eric.smith, pavel-lexyr, rhettinger priority: normal severity: normal status: open title: dataclasses.dataclass and collections.namedtuple do the same thing type: enhancement versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44768> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com