This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zuo
Recipients amaury.forgeotdarc, eric.araujo, pitrou, pwaller, rhettinger, srid, thead, zuo
Date 2011-03-27.20:40:00
SpamBayes Score 0.0018857128
Marked as misclassified No
Message-id <1301258401.58.0.340202583362.issue7796@psf.upfronthosting.co.za>
In-reply-to
Content
On python-ideas I have proposed an ABC being also a kind of a mix-in, potentially making namedtuple subclassing (with custom methods etc.) more convenient, e.g.:

    class MyRecord(namedtuple.abc):
        _fields = 'x y z'
        def _my_custom_method(self):
            return list(self._asdict().items())

or

    class MyAbstractRecord(namedtuple.abc):
        def _my_custom_method(self):
            return list(self._asdict().items())

    class AnotherAbstractRecord(MyAbstractRecord):
        def __str__(self):
            return '<<<{}>>>'.format(super().__str__())
 
    class MyRecord2(MyAbstractRecord):
        _fields = 'a, b'
 
    class MyRecord3(AnotherAbstractRecord):
        _fields = 'p', 'q', 'r'

Here is an experimental monkey-patcher adding the 'abc' attribute to namedtuple:

http://dpaste.org/T9w6/

I am not sure if it is worth preparing an actual patch based on it. If you think it is I could prepare one.
History
Date User Action Args
2011-03-27 20:40:01zuosetrecipients: + zuo, rhettinger, amaury.forgeotdarc, pitrou, thead, eric.araujo, pwaller, srid
2011-03-27 20:40:01zuosetmessageid: <1301258401.58.0.340202583362.issue7796@psf.upfronthosting.co.za>
2011-03-27 20:40:00zuolinkissue7796 messages
2011-03-27 20:40:00zuocreate