Message112792
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. |
|
Date |
User |
Action |
Args |
2010-08-04 11:48:15 | PAG | set | recipients:
+ PAG |
2010-08-04 11:48:15 | PAG | set | messageid: <1280922495.27.0.868058296674.issue9507@psf.upfronthosting.co.za> |
2010-08-04 11:48:13 | PAG | link | issue9507 messages |
2010-08-04 11:48:12 | PAG | create | |
|