This is the kernel of a really useful idea, IMO. In fact, I already proposed something related to this-- unification of dict-making APIs-- back in May:

https://mail.python.org/pipermail/python-ideas/2019-May/056491.html 

But I like the Struct ABC approach you've suggested, too. 

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler


On Wed, Oct 16, 2019 at 1:30 PM Steve Jorgensen <stevej@stevej.name> wrote:
I feel like this proposal is not quite right, but maybe the idea will provoke some thoughts about something similar that -would- be right.

The idea first came to me upon realizing that since `namedtuple` classes have no special base class beyond `tuple`, there should be some way of identifying them as being primarily structural, even though they are instances of `tuple` which, in other cases, usually means something that is primarily sequential.

It is easily possible to identify a namedtuple by checking to see whether it has an `_asdict` method, but it might be nice to formalize the way that struct-like objects are identified in a virtual base class and be something that had application beyond just checking whether a `tuple` is a `namedtuple`.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@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/AILX6XPDDYUB3MDZIPM5D77H5H6AFZMX/
Code of Conduct: http://python.org/psf/codeofconduct/