New submission from Paul Giannaros <p...@giannaros.org>: 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. ---------- components: Library (Lib) files: collections-namedtuple-repr.diff keywords: patch messages: 112792 nosy: PAG priority: normal severity: normal status: open title: namedtuple should not hardcode the class name in __repr__ type: behavior versions: Python 2.6, Python 2.7, Python 3.3 Added file: http://bugs.python.org/file18377/collections-namedtuple-repr.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9507> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com