Eric Snow added the comment: A NamedTuple ABC doesn't have to define any API (so that part could wait?)[1]. I see it as most useful for isinstance checks. Here's a solution along those lines:
class NamedTuple(Sequence): @classmethod def __subclasshook__(cls, C): if cls is NamedTuple: if any("_fields" in B.__dict__ for B in C.__mro__): return True return NotImplemented def namedtuple(...): ... NamedTuple.register(result) return result (or include NamedTuple in the bases in the template) For structseq support: class NamedTuple(Sequence): @classmethod def __subclasshook__(cls, C): if cls is NamedTuple: if any("_fields" in B.__dict__ or # for namedtuple "n_fields" in B.__dict__ # for structseq for B in C.__mro__): return True return NotImplemented [1] I agree there is still a problem if we define an ABC here with no API and then add some later. Then classes that inherit from NamedTuple would break later when we add an API (just `_fields`?). Not sure how much that is a concern though. Then again we could just close out issue1820 and actually establish the API. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7796> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com