On Thu, Jul 29, 2021 at 01:10:39AM -0000, pa...@lexyr.com wrote:

> then much of 
> the problem (i.e., people that want to have a simple data object use 
> two incompatible things depending on which parts of the the Python doc 
> they read first) simply fades away.

Why is that a problem?

I can write notes with a pen or a pencil. Sometimes I *need* a pen, or I 
*need* a pencil. But most of the time I will choose whichever happens to 
come to mind at the time. No big deal.

As far as I am concerned, the only problem here is that you are taking 
the "There should be one..." koan too seriously, and misinterpreting 
what it means. It does *not* mean "there shouldn't be more than one way 
to do two slightly different things".

Dataclasses are not a special kind of object, they are a framework for 
automating a number of common methods used in class definitions. 
Dataclasses are just classes with a fancy meta-API to automate common 
methods. As such, you are right: with sufficient cleverness, we could 
probably develop a dataclass API to generate named tuples.

But we already have an API to generate named tuples.

In the history of Python, named tuples came first. But even if 
dataclasses had come first, we would still want named tuples. We would 
need an API to create them. Why do you care whether that API is spelled 
"@dataclass(...)" or "collections.namedtuple(...)"?



-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/3YT7YWE4VYGZJTBPXU44X2YARJ2X46F5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to