This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pavel-lexyr
Recipients eric.smith, pavel-lexyr, rhettinger
Date 2021-07-28.20:42:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627504951.63.0.727220170445.issue44768@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-07-28 20:42:31pavel-lexyrsetrecipients: + pavel-lexyr, rhettinger, eric.smith
2021-07-28 20:42:31pavel-lexyrsetmessageid: <1627504951.63.0.727220170445.issue44768@roundup.psfhosted.org>
2021-07-28 20:42:31pavel-lexyrlinkissue44768 messages
2021-07-28 20:42:31pavel-lexyrcreate