Steve Jorgensen 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.

Along with this idea, maybe `namedtuple` should became a type (not just a 
callable as it is now) for classes produced by calling `namedtuple()`. The 
`namedtuple` type could in turn inherit from `tuple` and from `Record` (or 
`Struct` or whatever name is decided for that).
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/N7VQSW4IOWJYNVEDTO7ECOQCMMAGCXSB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to