[Python-Dev] namedtuple implementation grumble (original) (raw)

Antoine Pitrou antoine at python.org
Mon Jun 9 13:40:41 CEST 2014


Le 09/06/2014 00:05, Raymond Hettinger a écrit :

Another issue is that a straight abc wouldn't be sufficient. What we would really want is to check for is: 1) the presence of a fields tuple (an abc can do this) 2) to check that all of the attribute names specified in fields are defined (ABCMeta doesn't do this) 3) and that the type is a Sequence (ABCMeta can do this). An tricked-out ABC extension might be worth it if it provided some non-trivial mixin capabilities for implementing homegrown named tuples (not created by the factory function), but I don't think we want to go there.

Instead of an ABC, why not a simple is_namedtuple() function?

Regards

Antoine.



More information about the Python-Dev mailing list