On Thu, Jul 29, 2021 at 9:37 AM <pa...@lexyr.com> wrote:
>
> I was writing some code the other day, and it needed a quick-and-dirty data 
> structure definition for a set of related variables. I looked back at other 
> code to try be consistent, and found that I used dataclasses in some parts 
> and namedtuples in others. Both seemed the right thing to do at the time - 
> almost to the extent where I could change one way for the other and it would 
> still be the same code.
>
> You can easily get a dataclass represented as tuple and vice versa. The way 
> they work under the hood may be different, but the interfaces are very close. 
> Two different modules are doing practically the same thing!
>

Interfaces ARE frequently very similar, and that's deliberate. We have
tuples, lists, dicts, all using subscript notation. That's a good
thing! And if your code sometimes uses one and sometimes uses the
other, that seems like fairly good evidence that you find both of them
useful.

I think you just answered your own question :)

ChrisA
_______________________________________________
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/FZWMK6ZLQUOQRSZCGTIASS4F4RTHEVFE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to