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 PAG
Recipients PAG
Date 2010-08-04.11:48:12
SpamBayes Score 6.7068623e-10
Marked as misclassified No
Message-id <1280922495.27.0.868058296674.issue9507@psf.upfronthosting.co.za>
In-reply-to
Content
collections.namedtuple hardcodes the class name which is reported in the new type's __repr__. This is irritating when subclassing a namedtuple:

A = collections.namedtuple('A', '')
class B(A):
    pass
print B()  # shows 'A()'

It might not be often that they're subclassed, but it can be a useful way to add extra methods, properties, and documentation. Other classes often use the current instance's class name in the repr (e.g. collections.OrderedDict). The attached patch changes namedtuple to do this, includes a testcase, and updates the documentation.
History
Date User Action Args
2010-08-04 11:48:15PAGsetrecipients: + PAG
2010-08-04 11:48:15PAGsetmessageid: <1280922495.27.0.868058296674.issue9507@psf.upfronthosting.co.za>
2010-08-04 11:48:13PAGlinkissue9507 messages
2010-08-04 11:48:12PAGcreate